fix: prevent panics from unwrap calls and unsafe integer casts#273
Merged
vieiralucas merged 2 commits intomainfrom Apr 12, 2026
Merged
fix: prevent panics from unwrap calls and unsafe integer casts#273vieiralucas merged 2 commits intomainfrom
vieiralucas merged 2 commits intomainfrom
Conversation
- DynamoDB streams poller: clamp batch_size before i64→usize cast - DynamoDB: guard split_on_and/split_on_or with is_char_boundary checks - Step Functions: replace .unwrap() with match in set_at_path for non-object intermediates - API Gateway v2 CORS: replace .parse().unwrap() with .parse().ok() on user-controlled values - API Gateway v2 HTTP proxy: clamp negative timeout before i64→u64 cast
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.
Summary
batch_sizebeforei64→usizecast to prevent wrapping on negative valuessplit_on_and/split_on_orwithis_char_boundarychecks to prevent panics on non-ASCII expression strings.unwrap()with graceful bail-out inset_at_pathwhen intermediate path segments are non-objects.parse().unwrap()with.parse().ok()on user-controlled header values to prevent panics on malformed CORS configi64→u64castAddresses unresolved Cubic findings from PRs #232, #257, #241, #255, #255.
Test plan
cargo clippy --workspace --all-targets -- -D warningspassescargo test -p fakecloud-stepfunctions -p fakecloud-apigatewayv2 -p fakecloud-dynamodb)set_at_pathnon-object intermediate pathSummary by cubic
Removes several panic paths by replacing unsafe unwraps and clamping integer casts, improving resilience to malformed config and non-ASCII inputs without changing valid behavior.
fakecloud-server(DynamoDB Streams poller): clampbatch_sizewith.max(0)beforei64→usizecast.fakecloud-dynamodb: guardsplit_on_and/split_on_orwithis_char_boundaryto avoid panics on UTF‑8 expressions.fakecloud-stepfunctions: makeset_at_pathbail out when intermediate segments aren’t objects; added unit test.fakecloud-apigatewayv2(CORS): replace.parse().unwrap()with conditional inserts to avoid panics on malformed header values.fakecloud-apigatewayv2(HTTP proxy): clamp negative timeouts with.max(0)beforei64→u64cast.Written for commit c8878b7. Summary will update on new commits.