feat(clp-rust-utils): Add structs to support deserialization of AWS S3 event notifications sent via SQS.#1537
Conversation
WalkthroughAdds an SQS event submodule exposing S3 event types and deserialization logic, introduces strongly typed S3-related structs, re-exports the S3 API, and adds unit tests validating deserialization behaviour. Changes
Sequence DiagramsequenceDiagram
participant SQS as SQS JSON payload
participant Serde as serde_json
participant Types as clp_rust_utils::sqs::event::S3 types
rect rgb(230, 248, 255)
SQS->>Serde: deliver JSON
Serde->>Types: deserialize -> `S3`
end
alt valid S3 event
Types->>Caller: populated `records` → `Record` → `Entity` (`Bucket`, `Object`)
else invalid/unsupported schema
Serde->>Caller: returns serde_json::Error
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Pre-merge checks and finishing touches✅ Passed checks (2 passed)
✨ 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 |
| #[rustfmt::skip] | ||
| /// Example S3 messages copied from AWS documentation: | ||
| /// <https://docs.aws.amazon.com/AmazonS3/latest/userguide/notification-content-structure.html#notification-content-structure-examples> | ||
| const _EXAMPLE_DOC: () = (); |
There was a problem hiding this comment.
I don't have better ideas of how to make this doc legal to pass the formatter. Let me know if u know better options. @hoophalab
There was a problem hiding this comment.
I have no idea, either. Let's just skip rustfmt for now
There was a problem hiding this comment.
Actionable comments posted: 4
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (4)
components/clp-rust-utils/src/sqs.rs(1 hunks)components/clp-rust-utils/src/sqs/event.rs(1 hunks)components/clp-rust-utils/src/sqs/event/s3.rs(1 hunks)components/clp-rust-utils/tests/sqs_test.rs(1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: junhaoliao
Repo: y-scope/clp PR: 0
File: :0-0
Timestamp: 2025-10-22T21:02:31.113Z
Learning: Repository y-scope/clp: Maintain deterministic CI/builds for Rust; add a check to verify Cargo.lock is in sync with Cargo.toml without updating dependencies (non-mutating verification in clp-rust-checks workflow).
Learnt from: LinZhihao-723
Repo: y-scope/clp PR: 549
File: components/core/tests/test-ir_encoding_methods.cpp:1180-1186
Timestamp: 2024-10-01T07:59:11.208Z
Learning: In the context of loop constructs, LinZhihao-723 prefers using `while (true)` loops and does not consider alternative loop constructs necessarily more readable.
Learnt from: LinZhihao-723
Repo: y-scope/clp PR: 549
File: components/core/tests/test-ir_encoding_methods.cpp:1180-1186
Timestamp: 2024-10-08T15:52:50.753Z
Learning: In the context of loop constructs, LinZhihao-723 prefers using `while (true)` loops and does not consider alternative loop constructs necessarily more readable.
🔇 Additional comments (2)
components/clp-rust-utils/src/sqs.rs (1)
2-2: LGTM!The addition of the public event module is correct and follows Rust module conventions.
components/clp-rust-utils/tests/sqs_test.rs (1)
57-74: LGTM!The test provides good coverage of S3 event deserialization, validating both successful deserialization with field verification and proper rejection of invalid event formats.
Co-authored-by: hoophalab <200652805+hoophalab@users.noreply.github.com>
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (1)
components/clp-rust-utils/tests/sqs_test.rs(1 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: junhaoliao
Repo: y-scope/clp PR: 0
File: :0-0
Timestamp: 2025-10-22T21:02:31.113Z
Learning: Repository y-scope/clp: Maintain deterministic CI/builds for Rust; add a check to verify Cargo.lock is in sync with Cargo.toml without updating dependencies (non-mutating verification in clp-rust-checks workflow).
Learnt from: LinZhihao-723
Repo: y-scope/clp PR: 549
File: components/core/tests/test-ir_encoding_methods.cpp:1180-1186
Timestamp: 2024-10-01T07:59:11.208Z
Learning: In the context of loop constructs, LinZhihao-723 prefers using `while (true)` loops and does not consider alternative loop constructs necessarily more readable.
Learnt from: LinZhihao-723
Repo: y-scope/clp PR: 549
File: components/core/tests/test-ir_encoding_methods.cpp:1180-1186
Timestamp: 2024-10-08T15:52:50.753Z
Learning: In the context of loop constructs, LinZhihao-723 prefers using `while (true)` loops and does not consider alternative loop constructs necessarily more readable.
📚 Learning: 2024-10-07T21:35:04.362Z
Learnt from: AVMatthews
Repo: y-scope/clp PR: 543
File: components/core/src/clp_s/JsonParser.cpp:735-794
Timestamp: 2024-10-07T21:35:04.362Z
Learning: In `components/core/src/clp_s/JsonParser.cpp`, within the `parse_from_ir` method, encountering errors from `kv_log_event_result.error()` aside from `std::errc::no_message_available` and `std::errc::result_out_of_range` is anticipated behavior and does not require additional error handling or logging.
Applied to files:
components/clp-rust-utils/tests/sqs_test.rs
📚 Learning: 2024-10-08T15:52:50.753Z
Learnt from: AVMatthews
Repo: y-scope/clp PR: 543
File: components/core/src/clp_s/JsonParser.cpp:756-765
Timestamp: 2024-10-08T15:52:50.753Z
Learning: In `components/core/src/clp_s/JsonParser.cpp`, within the `parse_from_ir()` function, reaching the end of log events in a given IR is not considered an error case. The errors `std::errc::no_message_available` and `std::errc::result_out_of_range` are expected signals to break the deserialization loop and proceed accordingly.
Applied to files:
components/clp-rust-utils/tests/sqs_test.rs
🔇 Additional comments (2)
components/clp-rust-utils/tests/sqs_test.rs (2)
1-2: LGTM!The import correctly references the new S3 type from the SQS event module introduced in this PR.
8-46: LGTM!The example S3 PUT event payload correctly follows AWS's documented notification content structure and provides comprehensive test data.
…3 event notifications sent via SQS. (y-scope#1537)
Description
As the title suggests, this PR implements structs for AWS S3 SQS messages following these docs: https://docs.aws.amazon.com/AmazonS3/latest/userguide/notification-content-structure.html.
Checklist
breaking change.
Validation performed
Summary by CodeRabbit
New Features
Tests