Skip to content

fix(status): return 400 for codes outside 100-999 - #36

Merged
s3anw3 merged 1 commit into
seedvector:mainfrom
OpenDeernet:fix-status-out-of-range
Nov 7, 2026
Merged

s3anw3 merged 1 commit into
seedvector:mainfrom
OpenDeernet:fix-status-out-of-range

Conversation

@OpenDeernet

Copy link
Copy Markdown
Contributor

Fixes #35

/status/99 and /status/1000 used to come back as 200 OK because StatusCode::from_u16 fails and the handlers fall back to StatusCode::OK. This adds a range check in parse_weighted_codes, so these codes now get the same 400 {"error": "Invalid status code"} already used for unparsable codes (matching httpbin). It covers both the GET and POST handlers and comma-separated lists too.

Added a test for 99, 1000, 0 and 200,1000 on GET and POST. cargo test, cargo fmt --check and cargo clippy all pass locally.

Thanks for taking a look!

@s3anw3 s3anw3 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the fix! Validating codes in the shared parser correctly rejects out-of-range values before selection and covers both GET and POST, including comma-separated lists. The added regression test covers the reported cases. Local validation passed: 275 library tests, including one additional review-only test. No blocking findings.

@s3anw3
s3anw3 merged commit c1e03da into seedvector:main Nov 7, 2026
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.

/status/99 (and other out-of-range codes) returns 200 OK

2 participants