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

validate attributes when creating SQS queues #10820

Merged
merged 4 commits into from
May 16, 2024

Conversation

cloutierMat
Copy link
Contributor

Motivation

Looking into issue #10812, I realised that the attributes were not being validated at queue creation.

While the documentation does mention false as an appropriate value for this attribute, reports are dating back 2017 that providing it results in AttributeNameError.

Changes

The method validate_queue_attributes was already enforcing this behaviour but it wasn't called when originally creating the queue.

A test for fifo queue attributes is also now fixed. 😄

fix #10812

@cloutierMat cloutierMat added aws:sqs Amazon Simple Queue Service semver: patch Non-breaking changes which can be included in patch releases labels May 14, 2024
@cloutierMat cloutierMat self-assigned this May 14, 2024
@cloutierMat cloutierMat changed the title Validate attributes when creating the queue validate attributes when creating SQS queues May 14, 2024
Copy link

github-actions bot commented May 15, 2024

LocalStack Community integration with Pro

    2 files  ± 0      2 suites  ±0   1h 38m 11s ⏱️ + 1m 38s
2 954 tests +13  2 654 ✅ +14  300 💤  - 1  0 ❌ ±0 
2 956 runs  +13  2 654 ✅ +14  302 💤  - 1  0 ❌ ±0 

Results for commit d1d34d1. ± Comparison against base commit 3c4c463.

This pull request removes 12 and adds 25 tests. Note that renamed tests count towards both.
tests.aws.services.sns.test_sns.TestSNSFilter ‑ test_exists_filter_policy
tests.aws.services.sns.test_sns.TestSNSFilter ‑ test_exists_filter_policy_attributes_array
tests.aws.services.sns.test_sns.TestSNSFilter ‑ test_filter_policy
tests.aws.services.sns.test_sns.TestSNSFilter ‑ test_filter_policy_for_batch
tests.aws.services.sns.test_sns.TestSNSFilter ‑ test_filter_policy_on_message_body[False]
tests.aws.services.sns.test_sns.TestSNSFilter ‑ test_filter_policy_on_message_body[True]
tests.aws.services.sns.test_sns.TestSNSFilter ‑ test_filter_policy_on_message_body_array_attributes
tests.aws.services.sns.test_sns.TestSNSFilter ‑ test_filter_policy_on_message_body_array_of_object_attributes
tests.aws.services.sns.test_sns.TestSNSFilter ‑ test_filter_policy_on_message_body_dot_attribute
tests.aws.services.sns.test_sns.TestSNSFilter ‑ test_set_subscription_filter_policy_scope
…
tests.aws.services.sns.test_sns.TestSNSSubscriptionCrud ‑ test_list_subscriptions_by_topic_pagination
tests.aws.services.sns.test_sns.TestSNSSubscriptionHttp ‑ test_http_subscription_response
tests.aws.services.sns.test_sns_filter_policy.TestSNSFilterPolicyAttributes ‑ test_exists_filter_policy
tests.aws.services.sns.test_sns_filter_policy.TestSNSFilterPolicyAttributes ‑ test_exists_filter_policy_attributes_array
tests.aws.services.sns.test_sns_filter_policy.TestSNSFilterPolicyAttributes ‑ test_filter_policy
tests.aws.services.sns.test_sns_filter_policy.TestSNSFilterPolicyBody ‑ test_filter_policy_for_batch
tests.aws.services.sns.test_sns_filter_policy.TestSNSFilterPolicyBody ‑ test_filter_policy_on_message_body[False]
tests.aws.services.sns.test_sns_filter_policy.TestSNSFilterPolicyBody ‑ test_filter_policy_on_message_body[True]
tests.aws.services.sns.test_sns_filter_policy.TestSNSFilterPolicyBody ‑ test_filter_policy_on_message_body_array_attributes
tests.aws.services.sns.test_sns_filter_policy.TestSNSFilterPolicyBody ‑ test_filter_policy_on_message_body_array_of_object_attributes
…

♻️ This comment has been updated with latest results.

Copy link
Contributor

@simonrw simonrw left a comment

Choose a reason for hiding this comment

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

I will let the service owner(s) comment on the SQS changes, but the CFn changes look good to me. Just a non-critical suggestion for the future

Comment on lines 1 to 2
Conditions:
IsFifo: !Equals [ {{ is_fifo }}, "true"]
Copy link
Contributor

Choose a reason for hiding this comment

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

minor: this could be a CloudFormation parameter, rather than relying on our string interpolation:

Suggested change
Conditions:
IsFifo: !Equals [ {{ is_fifo }}, "true"]
Parameters:
IsFifo:
Type: String
Conditions:
IsFifo: !Equals [ !Ref IsFifo, "true"]

then deploy with

result = deploy_cfn_template(
        template_path=os.path.join(
            os.path.dirname(__file__), "../../../templates/sqs_fifo_autogenerate_name.yaml"
        ),
        parameters={"IsFifo": "false"},
        max_wait=240,
    )

Annoyingly CFn parameters cannot be booleans 🤦

@@ -33,8 +33,7 @@ def test_sqs_fifo_queue_generates_valid_name(deploy_cfn_template):
assert ".fifo" in result.outputs["FooQueueName"]


# FIXME: doesn't work on AWS. (known bug in cloudformation: https://github.com/aws-cloudformation/cloudformation-coverage-roadmap/issues/165)
@markers.aws.unknown
@markers.aws.validated
Copy link
Contributor

Choose a reason for hiding this comment

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

Woo! 🎉

Copy link
Member

@baermat baermat left a comment

Choose a reason for hiding this comment

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

LGTM 👍 thanks for tackling this :)

valid = [
k[1]
for k in inspect.getmembers(
QueueAttributeName, lambda x: isinstance(x, str) and not x.startswith("__")
Copy link
Member

Choose a reason for hiding this comment

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

purely curious, what's the reasoning behind the startswith clause, which attributes are weeded out here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

get_members returns all of the members and dunder methods, after filtering for str, I believe it is __name__ that was left.

@cloutierMat cloutierMat merged commit 98dbcbc into master May 16, 2024
30 checks passed
@cloutierMat cloutierMat deleted the fix-sqs-create-queue-validation branch May 16, 2024 16:32
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: Cannot create an SQS queue with FifoQueue: false
3 participants