Skip to content

Bug: idempotency logic should first validate the payload and then cache #3821

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

Closed
rubenfonseca opened this issue Feb 21, 2024 · 2 comments · Fixed by #3822
Closed

Bug: idempotency logic should first validate the payload and then cache #3821

rubenfonseca opened this issue Feb 21, 2024 · 2 comments · Fixed by #3822
Assignees
Labels
bug Something isn't working idempotency Idempotency utility

Comments

@rubenfonseca
Copy link
Contributor

Expected Behaviour

The idempotency utility should only cache the results from the persistence layer if the retrieved record passes payload tampering validation.

Current Behaviour

The results from the persistence layer are always written to the cache, even if it later fails tampering validation. This should be the other way around.

Code snippet

https://github.com/aws-powertools/powertools-lambda-python/blob/8ed384d6b58819843bcd9df8caeefa9e7001e450/aws_lambda_powertools/utilities/idempotency/persistence/base.py#L386-L388

Possible Solution

Change the logic

Steps to Reproduce

self._save_to_cache(data_record=record)
self._validate_payload(data_payload=data, stored_data_record=record)

Powertools for AWS Lambda (Python) version

latest

AWS Lambda function runtime

3.12

Packaging format used

PyPi

Debugging logs

No response

@rubenfonseca rubenfonseca added bug Something isn't working triage Pending triage from maintainers labels Feb 21, 2024
@heitorlessa heitorlessa self-assigned this Feb 21, 2024
@heitorlessa heitorlessa added idempotency Idempotency utility and removed triage Pending triage from maintainers labels Feb 21, 2024
@heitorlessa heitorlessa moved this from Triage to Working on it in Powertools for AWS Lambda (Python) Feb 21, 2024
@github-actions github-actions bot added the pending-release Fix or implementation already in dev waiting to be released label Feb 21, 2024
@heitorlessa heitorlessa linked a pull request Feb 21, 2024 that will close this issue
12 tasks
@heitorlessa heitorlessa moved this from Working on it to Coming soon in Powertools for AWS Lambda (Python) Feb 21, 2024
Copy link
Contributor

⚠️COMMENT VISIBILITY WARNING⚠️

This issue is now closed. Please be mindful that future comments are hard for our team to see.

If you need more assistance, please either tag a team member or open a new issue that references this one.

If you wish to keep having a conversation with other community members under this issue feel free to do so.

Copy link
Contributor

This is now released under 2.34.1 version!

@github-actions github-actions bot removed the pending-release Fix or implementation already in dev waiting to be released label Feb 21, 2024
@heitorlessa heitorlessa moved this from Coming soon to Shipped in Powertools for AWS Lambda (Python) Feb 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working idempotency Idempotency utility
Projects
Status: Shipped
Development

Successfully merging a pull request may close this issue.

2 participants