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

Update Request Serialization Protocol Tests #3378

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from

Conversation

jonathan343
Copy link
Contributor

@jonathan343 jonathan343 commented Feb 6, 2025

Note: This is the 2/2 PR for adding smithy generated protocol test support. The request serialization version is: #3378

Summary

  • Replaces the existing request serialization protocol tests in botocore/tests/unit/protocols/output with new tests generated from Smithy protocol test models.
  • Moves existing protocol tests are moved under botocore/tests/unit/protocols/legacy and will continue to run for additional coverage.
  • Makes updates to our serializers in botocore/serialize.py and protocol test runner in botocore/tests/unit/test_protocols.py for additional compliance with the smithy-generated protocol tests.

@codecov-commenter
Copy link

codecov-commenter commented Feb 6, 2025

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.07%. Comparing base (50465e9) to head (a39d223).

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@                    Coverage Diff                    @@
##           update-protocol-tests    #3378      +/-   ##
=========================================================
- Coverage                  93.08%   93.07%   -0.02%     
=========================================================
  Files                         66       66              
  Lines                      14485    14536      +51     
=========================================================
+ Hits                       13483    13529      +46     
- Misses                      1002     1007       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jonathan343 jonathan343 force-pushed the update-input-protocol-tests branch from a39d223 to 563781f Compare February 18, 2025 19:04
@jonathan343 jonathan343 changed the base branch from update-protocol-tests to develop February 18, 2025 19:05
@jonathan343 jonathan343 marked this pull request as ready for review February 18, 2025 19:11
@jonathan343 jonathan343 requested a review from SamRemis February 18, 2025 19:25
Comment on lines +183 to +187
input_members = (
operation_model.input_shape.members
if operation_model.input_shape
else {}
)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's possible for a service to not model an input shape for their operation. As of botocore-1.36.22 there are 73 operations across 33 services that don't model an input shape. Additionally, there are 23 services that use the hostPrefix endpoint trait.

In the case where a service operation doesn't model an input shape AND models the hostPrefix endpoint trait, the existing logic would result in the following error:

AttributeError: 'NoneType' object has no attribute 'members'

Solution: If the operation doesn't model an input shape, return an empty members dict ({}) and continue with normal resolution/validation.

host_prefix = self._expand_host_prefix(parameters, operation_model)
if host_prefix is not None:
serialized['host_prefix'] = host_prefix

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently, hostPrefix expansion happens at the end of the serialize_to_request method. In the case where no input shape is defined on the operation, serialize_to_request returns early and fails to expand the hostPrefix.

Solution: By moving the hostPrefix expansion earlier in this method (before we check if the input shape is None), we ensure the hostPrefix is always expanded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants