Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for queue numeric argument conversion #26967

Conversation

bartoszkubicki
Copy link

@bartoszkubicki bartoszkubicki commented Feb 21, 2020

Description (*)

If we want to declare queue (I bet this also occurs the same way for exchanges) with arguments and we use numeric type argument in queue_topology.xml it is casted to string and in corrected file it gets wrapped in incorrect type for rabbit. Example of configuration:

 <exchange name="test.dead_letter" type="topic" connection="amqp">
        <binding id="test" topic="#" destinationType="queue"
                 destination="test_dead_letter">
            <arguments>
                <argument name="x-dead-letter-exchange" xsi:type="string">test.retry</argument>
                <argument name="x-message-ttl" xsi:type="number">36000</argument>
            </arguments>
        </binding>
    </exchange>

Of course using string type doesn't help as we get also string. While creating such a queue we get error similar to:
PRECONDITION_FAILED - inequivalent arg 'x-message-ttl'for queue 'test_dead_letter' in vhost '\': received the value '36000' of type 'longstr' but current is none.

If PR will be accepted, please port to 2.3 as well.

Related Pull Requests

This one has to be fixed first, as for now we are not able to declare queue with ANY parameters
#26966

Manual testing scenarios (*)

  1. Declare queue with numeric argument, for example x-message-ttl
  2. ...

Questions or comments

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds are green)

Resolved issues:

  1. resolves [Issue] Fix for queue numeric argument conversion #29615: Fix for queue numeric argument conversion

@m2-assistant
Copy link

m2-assistant bot commented Feb 21, 2020

Hi @bartoszkubicki. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me 2.4-develop instance - deploy vanilla Magento instance

For more details, please, review the Magento Contributor Guide documentation.

@bartoszkubicki bartoszkubicki force-pushed the queue-exchange-argument-processor-fix branch 2 times, most recently from 5951404 to cc49897 Compare February 21, 2020 16:23
@bartoszkubicki bartoszkubicki changed the title Fix for numeric argument conversion Fix for queue numeric argument conversion Feb 21, 2020
@@ -17,22 +22,25 @@ trait ArgumentProcessor
* @param array $arguments
* @return array
*/
public function processArguments($arguments)
public function processArguments($arguments): array
{
$output = [];
foreach ($arguments as $key => $value) {
if (is_array($value)) {
$output[$key] = ['A', $value];
} elseif (is_int($value)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, using only is_numeric will be enough.
Thanks

Copy link
Author

@bartoszkubicki bartoszkubicki Feb 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you mean in scope of this PR is_int check should be removed, while keeping is_numeric check?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

up

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bartoszkubicki Yes, you are right, is_int check can be removed.

@ghost ghost assigned naydav Feb 21, 2020
@sidolov sidolov added Priority: P3 May be fixed according to the position in the backlog. Severity: S3 Affects non-critical data or functionality and does not force users to employ a workaround. labels Aug 17, 2020
@sidolov
Copy link
Contributor

sidolov commented Aug 17, 2020

@magento create issue

@@ -17,22 +22,25 @@ trait ArgumentProcessor
* @param array $arguments
* @return array
*/
public function processArguments($arguments)
public function processArguments($arguments): array
{
$output = [];
foreach ($arguments as $key => $value) {
if (is_array($value)) {
$output[$key] = ['A', $value];
} elseif (is_int($value)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bartoszkubicki Yes, you are right, is_int check can be removed.

@bartoszkubicki bartoszkubicki force-pushed the queue-exchange-argument-processor-fix branch from cc49897 to d60cbb9 Compare August 27, 2020 21:13
@bartoszkubicki
Copy link
Author

@naydav @sidolov corrected

@sidolov
Copy link
Contributor

sidolov commented Aug 27, 2020

@magento run all tests

@sidolov
Copy link
Contributor

sidolov commented Sep 1, 2020

@bartoszkubicki could you please cover changes with automated tests?

@@ -121,7 +132,7 @@ public function exchangeDataProvider()
'arguments' => [
'argument1' => 'value',
'argument2' => true,
'argument3' => 150,
'argument3' => '150',
Copy link
Contributor

@engcom-Foxtrot engcom-Foxtrot Oct 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea is to assert argument3 is a number.

@bartoszkubicki bartoszkubicki force-pushed the queue-exchange-argument-processor-fix branch from c0fd215 to 8c8b9cf Compare October 12, 2020 18:35
@bartoszkubicki
Copy link
Author

@magento run all tests

engcom-Foxtrot added a commit to andrewbess/magento2ce that referenced this pull request Oct 13, 2020
@engcom-Foxtrot
Copy link
Contributor

@magento run all tests

@engcom-Foxtrot engcom-Foxtrot added QA: Ready to add to Regression Scope Should be analyzed and added to Regression Testing Scope(if applicable) and removed Progress: extended testing labels Oct 16, 2020
@engcom-Foxtrot
Copy link
Contributor

QA passed.

@engcom-Alfa engcom-Alfa added QA: Added to Regression Scope Scenario was analysed and added to Regression Testing Scope and removed QA: Ready to add to Regression Scope Should be analyzed and added to Regression Testing Scope(if applicable) labels Oct 16, 2020
@ghost ghost added the Progress: accept label Oct 16, 2020
@magento-engcom-team magento-engcom-team merged commit fad43a1 into magento:2.4-develop Oct 24, 2020
@m2-assistant
Copy link

m2-assistant bot commented Oct 24, 2020

Hi @bartoszkubicki, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

@bartoszkubicki
Copy link
Author

Please port it to Magento 2.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auto-Tests: Covered All changes in Pull Request is covered by auto-tests Component: Amqp Event: MageCONF CD 2020 has dependency Priority: P3 May be fixed according to the position in the backlog. Progress: accept QA: Added to Regression Scope Scenario was analysed and added to Regression Testing Scope Release Line: 2.4 Risk: medium Severity: S3 Affects non-critical data or functionality and does not force users to employ a workaround. Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

[Issue] Fix for queue numeric argument conversion
8 participants