Skip to content

fix(idempotency): apply jmespath_options to payload_validation_jmespath - #8474

Open
Om-singhaI wants to merge 1 commit into
aws-powertools:developfrom
Om-singhaI:fix/idempotency-payload-validation-jmespath-options
Open

Om-singhaI wants to merge 1 commit into
aws-powertools:developfrom
Om-singhaI:fix/idempotency-payload-validation-jmespath-options

Conversation

@Om-singhaI

Copy link
Copy Markdown

Issue number: closes #8473

Summary

Changes

BasePersistenceLayer passes jmespath_options to the idempotency key search but not to the payload_validation_jmespath search in _get_hashed_payload. By default those options hold the Powertools functions, so powertools_json(), powertools_base64(), powertools_base64_gzip() and any custom function raised UnknownFunctionError in the validation expression.

save_inprogress hashes the payload before it writes the record. So every call failed with IdempotencyPersistenceLayerError and the handler never ran.

  • _get_hashed_payload now passes the same jmespath.Options as the key search.
  • New functional test with powertools_json(body) in both expressions. The same order replays the stored response, and a changed amount raises IdempotencyValidationError.
  • New functional test for a function from custom jmespath_options used in payload_validation_jmespath.

User experience

Before: payload_validation_jmespath="powertools_json(body).amount" fails every call with Unknown function: powertools_json().

After: the handler runs, and a repeat request with a changed amount raises IdempotencyValidationError.

Testing:

  • Both new tests in tests/functional/idempotency/_boto3/test_idempotency.py fail on develop with Unknown function errors and pass here.
  • tests/functional/idempotency/_boto3, tests/functional/idempotency/_pydantic and tests/unit/idempotency: 133 passed.
  • ruff format --check and ruff check pass on both files. mypy is clean on persistence/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.

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.
@Om-singhaI
Om-singhaI requested a review from a team as a code owner September 18, 2026 20:45
@Om-singhaI
Om-singhaI requested a review from hjgraca September 18, 2026 20:45
@boring-cyborg

boring-cyborg Bot commented Sep 18, 2026

Copy link
Copy Markdown

Thanks a lot for your first contribution! Please check out our contributing guidelines and don't hesitate to ask whatever you need.
In the meantime, check out the #python channel on our Powertools for AWS Lambda Discord: Invite link

@boring-cyborg boring-cyborg Bot added the tests label Sep 18, 2026
@powertools-for-aws-oss-automation powertools-for-aws-oss-automation Bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Sep 18, 2026
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Denotes a PR that changes 30-99 lines, ignoring generated files. tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: payload_validation_jmespath ignores jmespath_options, so powertools_json() raises Unknown function

1 participant