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

SqsClient sending requests to Queue URL with json protocol #2822

Closed
bentsku opened this issue Nov 14, 2023 · 4 comments · Fixed by #2823
Closed

SqsClient sending requests to Queue URL with json protocol #2822

bentsku opened this issue Nov 14, 2023 · 4 comments · Fixed by #2823
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.

Comments

@bentsku
Copy link

bentsku commented Nov 14, 2023

Describe the bug

It seems the PHP SDK is still sending SendMessage and other queue related requests to the Queue URL when using the json protocol, when it should target the root URL as per the documentation and the other SDKs behavior.

It works with AWS, but it does not really follow the json protocol specifications.

From the Smithy specs:
https://smithy.io/2.0/aws/protocols/aws-json-1_0-protocol.html#protocol-behaviors

Every request for the awsJson1_0 protocol MUST be sent to the root URL (/) using the HTTP "POST" method.

I believe this should be fixed to be in compliance with the Smithy specification for the awsJson1_0 protocol.

Expected Behavior

The AWS PHP SDK should send all requests to the root URL when targeting SQS with the json protocol.

Current Behavior

The PHP SDK is still sending requests to the Queue URL, as shown by this log:

Aws\Result Object
(
    [data:Aws\Result:private] => Array
        (
            [Messages] => Array
                (
                )

            [@metadata] => Array
                (
                    [statusCode] => 200
                    [effectiveUri] => https://sqs.us-east-2.amazonaws.com/test-queue
                    [headers] => Array
                        (
                            [x-amzn-requestid] => REQ-ID
                            [date] => Tue, 14 Nov 2023 17:32:57 GMT
                            [content-type] => application/x-amz-json-1.0
                            [content-length] => 15
                            [connection] => keep-alive
                        )

                    [transferStats] => Array
                        (
                            [http] => Array
                                (
                                    [0] => Array
                                        (
                                        )

                                )

                        )

                )

        )

    [monitoringEvents:Aws\Result:private] => Array
        (
        )

)

Especially this part: [effectiveUri] => https://sqs.us-east-2.amazonaws.com/test-queue

Reproduction Steps

<?php

use Aws\Sqs\SqsClient;

require '../vendor/autoload.php';

$client = new SqsClient(['region' => 'us-east-2']);
$response = $client->receiveMessage([
    'QueueUrl' => 'test-queue',
    'MaxNumberOfMessages' => 1,
    'WaitTimeSeconds' => 0
]);

print_r($response);

Possible Solution

Maybe the issue lies here, for the new protocol we don't need to append the QueueUrl anymore to the endpoint?

$list->appendBuild($this->queueUrl(), 'sqs.queue_url');

Additional Information/Context

No response

SDK version used

3.286.1

Environment details (Version of PHP (php -v)? OS name and version, etc.)

PHP 8.2.12 / macOS Sonoma 14.1

@bentsku bentsku added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Nov 14, 2023
@stobrien89
Copy link
Member

@bentsku,

Thanks for letting us know. SQS recently migrated from query to json protocol— looks like the culprit is this middleware we add to the SQS client's handler list. This is no longer needed.

@bentsku
Copy link
Author

bentsku commented Nov 14, 2023

Awesome, thanks for investigating!

Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@bentsku
Copy link
Author

bentsku commented Nov 15, 2023

Thank you for providing such a quick fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants