Repository navigation
fix(data-classes): don't URL-decode the object key of S3 EventBridge events - #8900
Open
nc-dirknilius wants to merge 1 commit into
Open
nc-dirknilius wants to merge 1 commit into
nc-dirknilius wants to merge 1 commit into
Conversation
…events S3 Event Notifications carry a URL-encoded object key, but S3 events sent through EventBridge carry it unencoded. Decoding it altered keys containing `+` or a percent-encoded sequence, e.g. `a+b.txt` became `a b.txt`.
|
This branch has not been deployed
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 #8901
Summary
Changes
S3EventBridgeNotificationEvent(...).detail.object.keyappliedunquote_plusto the key. S3 Event Notifications carry a URL-encoded key, but S3 events sent through EventBridge carry it unencoded. Decoding it altered keys containing+or a percent-encoded sequence. The key is now returned as is.S3Eventis unchanged. The docs page and its example don't mention the decoding, so they need no change.References:
User experience
event.detail.object.keyfor an object in the bucket:a+b.txta b.txta+b.txta%20b.txta b.txta%20b.txtfolder name/ü (1).txtfolder name/ü (1).txtCompatibility (ADR 0006): this changes observable behavior, but only for keys containing
+or a percent-encoded sequence. For those, the old value wasn't the key of the object, so reading it failed or returned a different object. Code that passes an already encoded key in a hand-written test event would notice the change.Verification
Real event: an object with a space and a
+in its key was uploaded to a bucket with EventBridge enabled. The event received by a Lambda function through an EventBridge rule contained the unencoded key (names replaced, other fields removed), and reading the object with the decoded key failed:{"detail-type": "Object Created", "detail": {"object": {"key": "folder name/a+b.txt"}}}Tests: added a test with four keys. Two of them (
a+b.txt,a%20b.txt) fail ondevelop, and all pass with the fix.uv run --locked pytest tests/unit/data_classespasses on Python 3.10 to 3.14.ruffandmypypass.An AI assistant helped to write this PR and to run these checks.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.