Thanks to visit codestin.com
Credit goes to github.com

Skip to content

add ability to patch botocore specs #6812

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

Merged
merged 3 commits into from
Sep 5, 2022
Merged

add ability to patch botocore specs #6812

merged 3 commits into from
Sep 5, 2022

Conversation

thrau
Copy link
Member

@thrau thrau commented Sep 3, 2022

This PR adds a PatchingLoader to ASF, which allows dynamic patching of botocore specs using jsonpatch.

This is mainly needed for s3 exception and response types, where the status codes defined in the spec are often missing or differ from what AWS actually returns. Some exception types are also missing custom attributes.

Patches are collected into spec-patches.json which is just a dictionary of botocore spec path -> jsonpatch document for that spec.
I also added an example patch to demonstrate how to use it.

@alexrashed i hope you find this to be an acceptable compromise between the two extremes of patching botocore objects vs providing our own spec files. 🙂 by adding patched services to test_generated_code_compiles, we make sure that the patches are actually compatible with the spec, so that, should the spec diverge, we immediately get notified. (Jsonpatch is pretty picky on JSON shapes being compatible with patches)

if you want changes, please feel free to edit and merge the PR

@thrau thrau requested review from alexrashed and steffyP September 3, 2022 13:30
@thrau thrau temporarily deployed to localstack-ext-tests September 3, 2022 13:31 Inactive
@coveralls
Copy link

coveralls commented Sep 3, 2022

Coverage Status

Coverage decreased (-0.004%) to 91.492% when pulling b39d050 on asf-patch-specs into 5fafd1b on master.

@github-actions
Copy link

github-actions bot commented Sep 3, 2022

LocalStack integration with Pro

       3 files  ±0         3 suites  ±0   1h 12m 26s ⏱️ -39s
1 254 tests +1  1 213 ✔️ +1  41 💤 ±0  0 ±0 
1 679 runs  +1  1 607 ✔️ +1  72 💤 ±0  0 ±0 

Results for commit b39d050. ± Comparison against base commit 5fafd1b.

♻️ 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.

This is a perfect compromise:

  • Since we still use the original spec files coming with botocore (and don't maintain our own fork), we can still rely on the automatic spec updates w/ botocore and our ASF update action.
  • The spec-patches.json is a perfect log-book for our changes where we can easily add new patches.

I was a bit worried if the patched service specs are used by all components in the loop (especially when using the fallback / forwarding mechanisms), therefore I wrote a small test to verify that. In addition, I activated the s3 test as suggested by @thrau.

@steffyP From my side this would be good to go. Let me know if it's fine for you as well, if you would do things differently, or if you are missing any features concerning the spec patching. 🚀

@alexrashed alexrashed temporarily deployed to localstack-ext-tests September 5, 2022 11:50 Inactive
Copy link
Member

@steffyP steffyP 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 adding this feature

@alexrashed alexrashed merged commit 1483a4e into master Sep 5, 2022
@alexrashed alexrashed deleted the asf-patch-specs branch September 5, 2022 13:09
@alexrashed alexrashed mentioned this pull request Sep 6, 2022
3 tasks
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.

4 participants