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

feature request: Adds the ability to accept SQS requests using the AWS JSON protocol within LocalStack. #10821

Open
1 task done
intptr-t opened this issue May 15, 2024 · 0 comments
Labels
area: integration/aws-sdk-javascript Issues related to AWS JavaScript SDK aws:sqs Amazon Simple Queue Service status: backlog Triaged but not yet being worked on type: feature New feature, or improvement to an existing feature

Comments

@intptr-t
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Feature description

Adds the ability to accept SQS requests using the AWS JSON protocol within LocalStack.

Current issues

We get a protocol error when I make API requests to SQS on LocalStack using the latest AWS SDK for JavaScript v3 or boto3.
According to the Amazon SQS AWS JSON protocol FAQs in Notes, it can be reproduced using boto3 >=1.28.82, botocore>=1.31.82, and >=v3.447.0 in JavaScript v3.

🧑‍💻 Implementation

No response

Anything else?

Example for JavaScript

Example Node.js code

const { SQSClient, ListQueuesCommand } = require("@aws-sdk/client-sqs");

const sqs = new SQSClient({endpoint: "http://localhost:4566", credentials: { accessKeyId: "foo", secretAccessKey: "bar", }, region: "us-east-1" });
sqs.send(new ListQueuesCommand())
  .then((res) => { console.log (res)})
  .catch((err) => { console.log (err)});

package.json

{
  "name": "node",
  "dependencies": {
    "@aws-sdk/client-sqs": "^3.576.0",
  }
}

error output

SyntaxError: Unexpected token '<', "<?xml vers"... is not valid JSON
  Deserialization error: to see the raw response, inspect the hidden field {error}.$response on this object.
    at JSON.parse (<anonymous>)
    at /Users/tomono/tmp/__tmp/node/node_modules/@aws-sdk/core/dist-cjs/submodules/protocols/index.js:112:19
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async parseJsonErrorBody (/Users/tomono/tmp/__tmp/node/node_modules/@aws-sdk/core/dist-cjs/submodules/protocols/index.js:125:17)
    at async de_CommandError (/Users/tomono/tmp/__tmp/node/node_modules/@aws-sdk/client-sqs/dist-cjs/index.js:1192:11)
    at async /Users/tomono/tmp/__tmp/node/node_modules/@smithy/middleware-serde/dist-cjs/index.js:35:20
    at async /Users/tomono/tmp/__tmp/node/node_modules/@smithy/core/dist-cjs/index.js:165:18
    at async /Users/tomono/tmp/__tmp/node/node_modules/@smithy/middleware-retry/dist-cjs/index.js:320:38
    at async /Users/tomono/tmp/__tmp/node/node_modules/@aws-sdk/middleware-logger/dist-cjs/index.js:34:22 {
  '$metadata': { attempts: 1, totalRetryDelay: 0 }
}

Example Python

Python code

import boto3

sqs = boto3.client(
    'sqs',
    region_name="us-east-1",
    endpoint_url="http://localhost:4566",
    aws_access_key_id="foo",
    aws_secret_access_key="bar",
)
sqs.list_queues()

requirements.txt

boto3==1.34.105
botocore==1.34.105
jmespath==1.0.1
python-dateutil==2.9.0.post0
s3transfer==0.10.1
six==1.16.0
urllib3==2.2.1

error output

Traceback (most recent call last):
  File "/Users/USERNAME/tmp/__tmp/python/test.py", line 10, in <module>
    sqs.list_queues()
  File "/Users/USERNAME/tmp/__tmp/python/venv/lib/python3.12/site-packages/botocore/client.py", line 565, in _api_call
    return self._make_api_call(operation_name, kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/USERNAME/tmp/__tmp/python/venv/lib/python3.12/site-packages/botocore/client.py", line 1021, in _make_api_call
    raise error_class(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (500) when calling the ListQueues operation (reached max retries: 4): <?xml version='1.0' encoding='utf-8'?>
<ErrorResponse xmlns="http://queue.amazonaws.com/doc/2012-11-05/"><Error><Code>InternalError</Code><Message>exception while calling sqs with unknown operation: Operation detection failed. Missing Action in request for query-protocol service ServiceModel(sqs).</Message></Error><RequestId>4ad5e260-74e1-4cc1-9858-4dd9353ae37b</RequestId></ErrorResponse>

Other Notes

Amazon SQS AWS JSON protocol FAQs

https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-json-faqs.html

AWS JSON protocol is used by SQS by default

If you check the ListQueues API reference, you will see that the AWS JSON protocol is the default (as of 2024-05-15).

https://docs.aws.amazon.com/ja_jp/AWSSimpleQueueService/latest/APIReference/API_ListQueues.html

@intptr-t intptr-t added status: triage needed Requires evaluation by maintainers type: feature New feature, or improvement to an existing feature labels May 15, 2024
@Anze1508 Anze1508 added aws:sqs Amazon Simple Queue Service area: integration/aws-sdk-javascript Issues related to AWS JavaScript SDK status: backlog Triaged but not yet being worked on and removed status: triage needed Requires evaluation by maintainers labels May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: integration/aws-sdk-javascript Issues related to AWS JavaScript SDK aws:sqs Amazon Simple Queue Service status: backlog Triaged but not yet being worked on type: feature New feature, or improvement to an existing feature
Projects
None yet
Development

No branches or pull requests

2 participants