add ability to patch botocore specs#6812
Merged
alexrashed merged 3 commits intomasterfrom Sep 5, 2022
Merged
Conversation
alexrashed
approved these changes
Sep 5, 2022
Member
alexrashed
left a comment
There was a problem hiding this comment.
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.jsonis 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. 🚀
steffyP
approved these changes
Sep 5, 2022
Member
steffyP
left a comment
There was a problem hiding this comment.
LGTM :) thanks for adding this feature
21 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a
PatchingLoaderto 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.jsonwhich 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