Skip to content

fix: replace unwraps on user input with proper error handling#280

Merged
vieiralucas merged 1 commit intomainfrom
worktree-fix-unwraps-user-input
Apr 12, 2026
Merged

fix: replace unwraps on user input with proper error handling#280
vieiralucas merged 1 commit intomainfrom
worktree-fix-unwraps-user-input

Conversation

@vieiralucas
Copy link
Copy Markdown
Member

@vieiralucas vieiralucas commented Apr 12, 2026

Summary

  • StepFunctions: parsed["StartAt"].as_str().unwrap() on user-provided JSON now returns InvalidDefinition error instead of panicking
  • SNS: serde_json::to_string().unwrap() in SetTopicAttributes now falls back to original value on serialization failure
  • S3: algo.parse().unwrap() for SSE headers in multipart upload now silently skips invalid header values
  • Bedrock: 8 bare .unwrap() calls after map lookups replaced with .expect() documenting the safety invariant (key validated while holding write lock)

Test plan

  • cargo clippy --workspace --all-targets -- -D warnings passes clean
  • cargo fmt --check passes clean
  • CI passes
  • Cubic review passes

Summary by cubic

Replaced unwraps on user-controlled input to prevent panics and return clear errors. Documented safety invariants for internal map lookups in fakecloud-bedrock.

  • Bug Fixes

    • fakecloud-stepfunctions: Missing StartAt now returns InvalidDefinition instead of panicking.
    • fakecloud-sns: SetTopicAttributes compacts Policy JSON and falls back to original value if serialization fails.
    • fakecloud-s3: Multipart upload ignores invalid SSE header values instead of inserting invalid headers.
  • Refactors

    • fakecloud-bedrock: Replaced bare .unwrap() after validated map lookups with .expect(...) and comments explaining the invariant.

Written for commit 8da9dfa. Summary will update on new commits.

- StepFunctions: handle missing StartAt field with InvalidDefinition error
- SNS: handle serde_json::to_string failure gracefully in SetTopicAttributes
- S3: handle invalid SSE header values in multipart upload initiation
- Bedrock: replace bare .unwrap() after map lookups with .expect() documenting
  the safety invariant (key validated while holding write lock)
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 9 files

@vieiralucas vieiralucas merged commit 2f1998f into main Apr 12, 2026
22 checks passed
@vieiralucas vieiralucas deleted the worktree-fix-unwraps-user-input branch April 12, 2026 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant