Skip to content

Conversation

@bentsku
Copy link
Contributor

@bentsku bentsku commented Sep 22, 2025

Motivation

This PR is part of a bigger initiative (see #13028) to implement support for the new Smithy Protocol smithy-rpc-v2-cbor, as well as the new Botocore multi-protocol support for single services (before, a service could only define one protocol)

This PR fixes the ASF / CloudWatch issues encountered during validating the full test suite (see #13173). Those were cherry picked to make the PR more digestible and understand which tests needed the fix.

A failure popped up when the exception message would be empty for the json and smithy-rpc-v2-cbor: the message field would not be serialized at all when the value would be empty. I validated that it's actually the behavior wanted as I knew the KMS serviced the same thing, and realized it had snapshot skips so fixed it for everything.

I've also found a major issue: the CBOR serializer absolutely needs a Botocore Shape in order to serialize any structure, but our custom-defined exception subclassed from CommonServiceException won't have any. I created a workaround by defining a fallback shape in case it is not defined, with the default field the serializer needs to properly encode the error.

This is also used by the json serializer, as it was doing some workaround by manually setting some keys in the dictionary.

I've also realized that the CloudWatch service will return different status code for exceptions, depending on the protocol and the x-amzn-query-mode request header, so this behavior has been implemented.

There is also a small fix for the boolean parsing in CBOR, showed by the test_set_alarm test.

Changes

  • validate 2 more tests that put into light bigger issues
  • create a QueryCompatibleProtocolMixin to add the utilities shared by json and smithy-rpc-v2-cbor to clean up
    • add logic for overriding response status code for Query Compatible services
  • rework the __type hack to use shallow copy instead of deep copy of shape members
  • centralize exception handling of CBOR serializers:
    • fix serialization of user-defined exceptions that are not present in the Botocore specs
    • add new empty field logic for json and smithy-rpc-v2-cbor serializer for exceptions
  • update logic for parsing boolean in CBOR parser

@bentsku bentsku self-assigned this Sep 22, 2025
@bentsku bentsku added aws:cloudwatch Amazon CloudWatch area: asf semver: patch Non-breaking changes which can be included in patch releases docs: skip Pull request does not require documentation changes labels Sep 22, 2025
@bentsku bentsku added this to the 4.9 milestone Sep 22, 2025
@bentsku bentsku force-pushed the cloudwatch-multi-protocol-runs-fixes branch 3 times, most recently from be37fe7 to 778c673 Compare September 22, 2025 17:18
@github-actions
Copy link

github-actions bot commented Sep 22, 2025

S3 Image Test Results (AMD64 / ARM64)

    2 files  ±0    2 suites  ±0   8m 13s ⏱️ -32s
  532 tests ±0  480 ✅ ±0   52 💤 ±0  0 ❌ ±0 
1 064 runs  ±0  960 ✅ ±0  104 💤 ±0  0 ❌ ±0 

Results for commit d4642d1. ± Comparison against base commit 4be950c.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Sep 22, 2025

Test Results - Preflight, Unit

22 259 tests  +1   20 518 ✅ +1   15m 58s ⏱️ -42s
     1 suites ±0    1 741 💤 ±0 
     1 files   ±0        0 ❌ ±0 

Results for commit d4642d1. ± Comparison against base commit 4be950c.

♻️ This comment has been updated with latest results.

@bentsku bentsku force-pushed the cloudwatch-multi-protocol-runs-fixes branch from 778c673 to bb7ab45 Compare September 22, 2025 17:39
@github-actions
Copy link

github-actions bot commented Sep 22, 2025

LocalStack Community integration with Pro

    2 files  ±0      2 suites  ±0   1h 58m 29s ⏱️ +23s
4 681 tests +7  4 359 ✅ +7  322 💤 ±0  0 ❌ ±0 
4 683 runs  +7  4 359 ✅ +7  324 💤 ±0  0 ❌ ±0 

Results for commit d4642d1. ± Comparison against base commit 4be950c.

This pull request removes 2 and adds 9 tests. Note that renamed tests count towards both.
tests.aws.services.cloudwatch.test_cloudwatch.TestCloudwatch ‑ test_set_alarm
tests.aws.services.cloudwatch.test_cloudwatch.TestCloudwatch ‑ test_set_alarm_invalid_input
tests.aws.services.cloudwatch.test_cloudwatch.TestCloudWatchMultiProtocol ‑ test_exception_serializing_with_no_shape_in_spec[json]
tests.aws.services.cloudwatch.test_cloudwatch.TestCloudWatchMultiProtocol ‑ test_exception_serializing_with_no_shape_in_spec[query]
tests.aws.services.cloudwatch.test_cloudwatch.TestCloudWatchMultiProtocol ‑ test_exception_serializing_with_no_shape_in_spec[smithy-rpc-v2-cbor]
tests.aws.services.cloudwatch.test_cloudwatch.TestCloudwatch ‑ test_set_alarm[json]
tests.aws.services.cloudwatch.test_cloudwatch.TestCloudwatch ‑ test_set_alarm[query]
tests.aws.services.cloudwatch.test_cloudwatch.TestCloudwatch ‑ test_set_alarm[smithy-rpc-v2-cbor]
tests.aws.services.cloudwatch.test_cloudwatch.TestCloudwatch ‑ test_set_alarm_invalid_input[json]
tests.aws.services.cloudwatch.test_cloudwatch.TestCloudwatch ‑ test_set_alarm_invalid_input[query]
tests.aws.services.cloudwatch.test_cloudwatch.TestCloudwatch ‑ test_set_alarm_invalid_input[smithy-rpc-v2-cbor]

♻️ This comment has been updated with latest results.

@bentsku bentsku force-pushed the cloudwatch-multi-protocol-runs-fixes branch from bb7ab45 to cc64c6a Compare September 22, 2025 19:26
@github-actions
Copy link

github-actions bot commented Sep 22, 2025

Test Results (amd64) - Acceptance

7 tests  ±0   5 ✅ ±0   3m 30s ⏱️ +10s
1 suites ±0   2 💤 ±0 
1 files   ±0   0 ❌ ±0 

Results for commit d4642d1. ± Comparison against base commit 4be950c.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Sep 22, 2025

Test Results - Alternative Providers

459 tests   - 781   287 ✅  - 414   7m 37s ⏱️ - 33m 10s
  2 suites  -   3   172 💤  - 367 
  2 files    -   3     0 ❌ ±  0 

Results for commit d4642d1. ± Comparison against base commit 4be950c.

This pull request removes 790 and adds 9 tests. Note that renamed tests count towards both.
tests.aws.services.cloudformation.api.test_changesets ‑ test_autoexpand_capability_requirement
tests.aws.services.cloudformation.api.test_changesets ‑ test_create_and_then_remove_non_supported_resource_change_set
tests.aws.services.cloudformation.api.test_changesets ‑ test_create_and_then_remove_supported_resource_change_set
tests.aws.services.cloudformation.api.test_changesets ‑ test_create_and_then_update_refreshes_template_metadata
tests.aws.services.cloudformation.api.test_changesets ‑ test_create_change_set_create_existing
tests.aws.services.cloudformation.api.test_changesets ‑ test_create_change_set_invalid_params
tests.aws.services.cloudformation.api.test_changesets ‑ test_create_change_set_missing_stackname
tests.aws.services.cloudformation.api.test_changesets ‑ test_create_change_set_no_changes
tests.aws.services.cloudformation.api.test_changesets ‑ test_create_change_set_update_nonexisting
tests.aws.services.cloudformation.api.test_changesets ‑ test_create_change_set_update_without_parameters
…
tests.aws.services.cloudwatch.test_cloudwatch.TestCloudWatchMultiProtocol ‑ test_exception_serializing_with_no_shape_in_spec[json]
tests.aws.services.cloudwatch.test_cloudwatch.TestCloudWatchMultiProtocol ‑ test_exception_serializing_with_no_shape_in_spec[query]
tests.aws.services.cloudwatch.test_cloudwatch.TestCloudWatchMultiProtocol ‑ test_exception_serializing_with_no_shape_in_spec[smithy-rpc-v2-cbor]
tests.aws.services.cloudwatch.test_cloudwatch.TestCloudwatch ‑ test_set_alarm[json]
tests.aws.services.cloudwatch.test_cloudwatch.TestCloudwatch ‑ test_set_alarm[query]
tests.aws.services.cloudwatch.test_cloudwatch.TestCloudwatch ‑ test_set_alarm[smithy-rpc-v2-cbor]
tests.aws.services.cloudwatch.test_cloudwatch.TestCloudwatch ‑ test_set_alarm_invalid_input[json]
tests.aws.services.cloudwatch.test_cloudwatch.TestCloudwatch ‑ test_set_alarm_invalid_input[query]
tests.aws.services.cloudwatch.test_cloudwatch.TestCloudwatch ‑ test_set_alarm_invalid_input[smithy-rpc-v2-cbor]
This pull request removes 375 skipped tests and adds 8 skipped tests. Note that renamed tests count towards both.
tests.aws.services.cloudformation.api.test_changesets ‑ test_create_and_then_update_refreshes_template_metadata
tests.aws.services.cloudformation.api.test_changesets ‑ test_create_change_set_no_changes
tests.aws.services.cloudformation.api.test_changesets ‑ test_create_change_set_update_without_parameters
tests.aws.services.cloudformation.api.test_changesets ‑ test_create_while_in_review
tests.aws.services.cloudformation.api.test_changesets ‑ test_describe_changeset_after_delete
tests.aws.services.cloudformation.api.test_changesets ‑ test_execute_change_set
tests.aws.services.cloudformation.api.test_changesets ‑ test_update_change_set_with_aws_novalue_repro
tests.aws.services.cloudformation.api.test_changesets ‑ test_using_pseudoparameters_in_places[condition]
tests.aws.services.cloudformation.api.test_changesets ‑ test_using_pseudoparameters_in_places[parameter]
tests.aws.services.cloudformation.api.test_changesets ‑ test_using_pseudoparameters_in_places[resource]
…
tests.aws.services.cloudwatch.test_cloudwatch.TestCloudWatchMultiProtocol ‑ test_exception_serializing_with_no_shape_in_spec[json]
tests.aws.services.cloudwatch.test_cloudwatch.TestCloudWatchMultiProtocol ‑ test_exception_serializing_with_no_shape_in_spec[query]
tests.aws.services.cloudwatch.test_cloudwatch.TestCloudWatchMultiProtocol ‑ test_exception_serializing_with_no_shape_in_spec[smithy-rpc-v2-cbor]
tests.aws.services.cloudwatch.test_cloudwatch.TestCloudwatch ‑ test_set_alarm[json]
tests.aws.services.cloudwatch.test_cloudwatch.TestCloudwatch ‑ test_set_alarm[smithy-rpc-v2-cbor]
tests.aws.services.cloudwatch.test_cloudwatch.TestCloudwatch ‑ test_set_alarm_invalid_input[json]
tests.aws.services.cloudwatch.test_cloudwatch.TestCloudwatch ‑ test_set_alarm_invalid_input[query]
tests.aws.services.cloudwatch.test_cloudwatch.TestCloudwatch ‑ test_set_alarm_invalid_input[smithy-rpc-v2-cbor]

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Sep 22, 2025

Test Results (amd64) - Integration, Bootstrap

    5 files  ±0      5 suites  ±0   2h 34m 51s ⏱️ - 1m 14s
5 055 tests +7  4 573 ✅ +7  482 💤 ±0  0 ❌ ±0 
5 061 runs  +7  4 573 ✅ +7  488 💤 ±0  0 ❌ ±0 

Results for commit d4642d1. ± Comparison against base commit 4be950c.

This pull request removes 2 and adds 9 tests. Note that renamed tests count towards both.
tests.aws.services.cloudwatch.test_cloudwatch.TestCloudwatch ‑ test_set_alarm
tests.aws.services.cloudwatch.test_cloudwatch.TestCloudwatch ‑ test_set_alarm_invalid_input
tests.aws.services.cloudwatch.test_cloudwatch.TestCloudWatchMultiProtocol ‑ test_exception_serializing_with_no_shape_in_spec[json]
tests.aws.services.cloudwatch.test_cloudwatch.TestCloudWatchMultiProtocol ‑ test_exception_serializing_with_no_shape_in_spec[query]
tests.aws.services.cloudwatch.test_cloudwatch.TestCloudWatchMultiProtocol ‑ test_exception_serializing_with_no_shape_in_spec[smithy-rpc-v2-cbor]
tests.aws.services.cloudwatch.test_cloudwatch.TestCloudwatch ‑ test_set_alarm[json]
tests.aws.services.cloudwatch.test_cloudwatch.TestCloudwatch ‑ test_set_alarm[query]
tests.aws.services.cloudwatch.test_cloudwatch.TestCloudwatch ‑ test_set_alarm[smithy-rpc-v2-cbor]
tests.aws.services.cloudwatch.test_cloudwatch.TestCloudwatch ‑ test_set_alarm_invalid_input[json]
tests.aws.services.cloudwatch.test_cloudwatch.TestCloudwatch ‑ test_set_alarm_invalid_input[query]
tests.aws.services.cloudwatch.test_cloudwatch.TestCloudwatch ‑ test_set_alarm_invalid_input[smithy-rpc-v2-cbor]

♻️ This comment has been updated with latest results.

Copy link
Member

@alexrashed alexrashed left a comment

Choose a reason for hiding this comment

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

Wow, that's quite a deep dive! 🤿 🤩
With the changes here and the strong similarities between the CBOR and JSON serializers, I am really wondering if we are missing an abstraction level which could simplify the two serializers and their weird special behavior in combination with the query protocol and the shape handling. Specifically also when looking at the changes in the _serialize_error method in the two serializers. What do you think?

…l Mixin, rework the `__type` hack to do a shallow copy
@bentsku bentsku requested a review from alexrashed September 23, 2025 10:03
Copy link
Member

@alexrashed alexrashed left a comment

Choose a reason for hiding this comment

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

Awesome! Thanks for addressing the comments! The default response serializer are minimal now, and the weird query handling is nicely encapsulated in the mixin! 💯

value: dict,
shape: Shape | None,
name: str | None = None,
shape_members: dict[str, Shape] | None = None,
Copy link
Member

Choose a reason for hiding this comment

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

nit: It think it would be good to mention why the signature of this _serialize_type_structure differs from all the others (as it's also used for the specific error serialization).

@bentsku bentsku merged commit 4d7c543 into main Sep 23, 2025
15 checks passed
@bentsku bentsku deleted the cloudwatch-multi-protocol-runs-fixes branch September 23, 2025 11:41
@alexrashed alexrashed added the notes: skip Pull request does not have to be mentioned in the release notes label Sep 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: asf aws:cloudwatch Amazon CloudWatch docs: skip Pull request does not require documentation changes notes: skip Pull request does not have to be mentioned in the release notes 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.

3 participants