fix(log-ingestor): URL-decode S3 object keys from SQS event notifications (fixes #2225).#2299
fix(log-ingestor): URL-decode S3 object keys from SQS event notifications (fixes #2225).#2299LinZhihao-723 wants to merge 3 commits into
Conversation
WalkthroughThis PR fixes a bug where the log-ingestor stored percent-encoded S3 object keys from SQS events without decoding them. The fix adds the ChangesS3 Object Key URL Decoding
🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@components/log-ingestor/src/ingestion_job/sqs_listener.rs`:
- Around line 210-213: In extract_object_metadata, avoid panicking on an empty
decoded S3 key and stop using the form-name/value parser: replace the
url::form_urlencoded::parse(record.s3.object.key.as_bytes()) + expect(...)
pattern with a percent-decoding call (e.g. percent_decode_str or equivalent) on
record.s3.object.key to decode the whole key as a single value, then if the
decoded string is empty return None instead of calling
NonEmptyString::new(...).expect(...); construct the NonEmptyString only when
decoded_key is non-empty and propagate None from extract_object_metadata for
empty or invalid keys.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: e2bcaa90-2b1e-4db0-9ffc-f3a442faa2f5
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (3)
components/log-ingestor/Cargo.tomlcomponents/log-ingestor/src/ingestion_job/sqs_listener.rscomponents/log-ingestor/tests/test_utils.rs
Description
This PR fixes #2225.
SQS forwards S3 notifications by encoding the key using
application/x-www-form-urlencoded(see https://docs.aws.amazon.com/AmazonS3/latest/userguide/notification-content-structure.html?utm_source=chatgpt.com). That means the SQS listener needs to unconditionally decode the received S3 key. This PR adds the decoding logic into the existing listener framework.This PR also adds test cases for S3 key encoding, by introducing
,&, and=characters in the submitted mock S3 objects. The submitted objects also contain keys that don't require any form URL encoding. The overall test cases make sure that:Checklist
breaking change.
Validation performed
Summary by CodeRabbit
Release Notes