Skip to content

Conversation

kshitijkohli
Copy link
Contributor

@kshitijkohli kshitijkohli commented Oct 19, 2024

Motivation

Raising a fix for an open issue in SQS flow of Localstack.
Fixes #11576

Changes

There was a bug in Localstack SQS put message in Standard SQS flow. Principally, standard SQS put calls do not support messagegroupid parameter to be passed. Current implementation of localstack allows "" ie empty string to be passed as messagegroupid while publishing to localstack, whereas same api request to actual AWS sqs throws an exception. Added an additional check in code which checks messagegroupid should not be any string ( having values or empty ) in case of standard sqs put message. If the parameter is an instance of the string, throw exception

Copy link
Contributor

@localstack-bot localstack-bot left a comment

Choose a reason for hiding this comment

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

Welcome to LocalStack! Thanks for raising your first Pull Request and landing in your contributions. Our team will reach out with any reviews or feedbacks that we have shortly. We recommend joining our Slack Community and share your PR on the #community channel to share your contributions with us. Please make sure you are following our contributing guidelines and our Code of Conduct.

@localstack-bot
Copy link
Contributor

localstack-bot commented Oct 19, 2024

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@kshitijkohli kshitijkohli force-pushed the localstack-issue-11576 branch from ad43249 to c117a3f Compare October 19, 2024 21:16
@kshitijkohli
Copy link
Contributor Author

I have read the CLA Document and I hereby sign the CLA

localstack-bot added a commit that referenced this pull request Oct 19, 2024
@kshitijkohli
Copy link
Contributor Author

Hi @thrau , @baermat , @gregfurman Could you please add the semver: patch label to this PR? It contains a small, backward-compatible bug fix. I don't see the access to be able to add the labels. Thank you!

thrau
thrau previously requested changes Oct 19, 2024
Copy link
Member

@thrau thrau left a comment

Choose a reason for hiding this comment

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

hey @kshitijkohli, thanks for the contribution!

would you please add a snapshot test case so we can avoid regressions? you can find out more in our contributor docs here.

something like this:

    @markers.aws.unknown
    def test_send_message_to_standard_queue_with_empty_message_group_id(self, sqs_create_queue, aws_client, snapshot):
        queue = sqs_create_queue()

        with pytest.raises(ClientError) as e:
            aws_client.sqs.send_message(QueueUrl=queue, MessageBody="message", MessageGroupId="")

        snapshot.match("error", e.value.response)

i think if we add and run this we may find that the error message isn't quite correct either. once we understand the full scope of the change i'm happy to set the semver label!

@kshitijkohli
Copy link
Contributor Author

@thrau Pushed the snapshot tests

@gregfurman gregfurman added aws:sqs Amazon Simple Queue Service semver: patch Non-breaking changes which can be included in patch releases labels Oct 21, 2024
@gregfurman gregfurman added this to the Playground milestone Oct 21, 2024
@gregfurman
Copy link
Contributor

gregfurman commented Oct 21, 2024

Hey @kshitijkohli 😄

When you ran your parity test, did you remember to point your client to snapshot against AWS? The relevant snippet of the contributing docs that Thomas linked is the How to write Parity tests:

Run the test against AWS: use the parameter --snapshot-update (or the environment variable SNAPSHOT_UPDATE=1) and set the environment variable as TEST_TARGET=AWS_CLOUD.

In addition, this section on Integration Testing (against AWS) is definitely also relevant!

Once you've setup your testing suite to be able to snapshot against AWS, you can run the test again with those flags enabled:

make TEST_TARGET=AWS_CLOUD SNAPSHOT_UPDATE=1 TEST_PATH="tests/aws/services/sqs/test_sqs.py::TestSqsProvider::test_send_message_to_standard_queue_with_empty_message_group_id"

Otherwise, I'd also be happy to generate the snapshot for you and push to your feature branch if that's something you'd prefer 🙂

Copy link
Contributor

@gregfurman gregfurman left a comment

Choose a reason for hiding this comment

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

LGTM 💯 Once the CI passes happy for this to go in. Thanks again for the contribution!

FYI: I just ran the test (SNAPSHOT_UPDATE=0; TEST_TARGET=AWS_CLOUD) against AWS to generate that *.validation.json 🙂

@gregfurman gregfurman dismissed thrau’s stale review November 26, 2024 07:56

Addressed comments

@gregfurman gregfurman force-pushed the localstack-issue-11576 branch from 85acdf2 to a75d885 Compare December 18, 2024 16:51
@gregfurman gregfurman merged commit 126777f into localstack:master Dec 24, 2024
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aws:sqs Amazon Simple Queue Service semver: patch Non-breaking changes which can be included in patch releases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: Standard SQS queue accepts empty MessageGroupId
4 participants