fix(idempotency): apply jmespath_options to payload_validation_jmespath - #8474
Open
Om-singhaI wants to merge 1 commit into
Open
Om-singhaI wants to merge 1 commit into
Om-singhaI wants to merge 1 commit into
Conversation
The idempotency key search passes jmespath_options (by default the Powertools functions like powertools_json), but the payload validation search didn't pass any options. Any payload_validation_jmespath using powertools_json, powertools_base64, powertools_base64_gzip or a custom function raised "Unknown function" when hashing the payload, so every invocation failed with IdempotencyPersistenceLayerError before the handler ran. Pass the same options to the payload validation search.
|
Thanks a lot for your first contribution! Please check out our contributing guidelines and don't hesitate to ask whatever you need. |
|
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.



Issue number: closes #8473
Summary
Changes
BasePersistenceLayerpassesjmespath_optionsto the idempotency key search but not to thepayload_validation_jmespathsearch in_get_hashed_payload. By default those options hold the Powertools functions, sopowertools_json(),powertools_base64(),powertools_base64_gzip()and any custom function raisedUnknownFunctionErrorin the validation expression.save_inprogresshashes the payload before it writes the record. So every call failed withIdempotencyPersistenceLayerErrorand the handler never ran._get_hashed_payloadnow passes the samejmespath.Optionsas the key search.powertools_json(body)in both expressions. The same order replays the stored response, and a changed amount raisesIdempotencyValidationError.jmespath_optionsused inpayload_validation_jmespath.User experience
Before:
payload_validation_jmespath="powertools_json(body).amount"fails every call withUnknown function: powertools_json().After: the handler runs, and a repeat request with a changed amount raises
IdempotencyValidationError.Testing:
tests/functional/idempotency/_boto3/test_idempotency.pyfail on develop withUnknown functionerrors and pass here.tests/functional/idempotency/_boto3,tests/functional/idempotency/_pydanticandtests/unit/idempotency: 133 passed.ruff format --checkandruff checkpass on both files. mypy is clean onpersistence/base.py.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.