Skip to content

fix: return 400 instead of 500 for redirect endpoints with n=0 - #768

Open
Anga205 wants to merge 1 commit into
postmanlabs:masterfrom
Anga205:master
Open

Anga205 wants to merge 1 commit into
postmanlabs:masterfrom
Anga205:master

Conversation

@Anga205

@Anga205 Anga205 commented Nov 26, 2026

Copy link
Copy Markdown

GET /redirect/0, /relative-redirect/0 and /absolute-redirect/0 hit assert n > 0 in httpbin/core.py. A zero count is caller input, not a server fault, but the assertion produced a 500.

Replace the assertions with a 400 response using the existing error_response helper. Behavior for n >= 1 is unchanged. Added a regression test that requests zero from all three endpoints and checks for 400.

Validation: python -W error::SyntaxWarning test_httpbin.py: 131 passed, 1 skipped (Python 3.13). Two files changed, +12/-3, no new dependencies.

/redirect/0, /relative-redirect/0 and /absolute-redirect/0 asserted n > 0, so a zero count raised AssertionError and produced a 500. Return a 400 client error instead, leaving n >= 1 behavior unchanged.

Add a regression test covering all three endpoints with n=0.

This branch has not been deployed

No deployments
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