Fix: Handle invalid HTTP status codes properly#1847
Open
ptanh05 wants to merge 1 commit into
Open
Conversation
Fix: Handle invalid HTTP status codes properly Previously, http_status_to_exit_status() would return SUCCESS for invalid status codes (< 100 or >= 600), which is incorrect behavior. This fix ensures: - Status codes 100-199 (Informational) return SUCCESS - Status codes 200-299 (Success) return SUCCESS - Status codes 300-399 return ERROR_HTTP_3XX (unless follow=True) - Status codes 400-499 return ERROR_HTTP_4XX - Status codes 500-599 return ERROR_HTTP_5XX - Invalid codes (< 100 or >= 600) now return ERROR instead of SUCCESS Added comprehensive test coverage for edge cases including informational responses and invalid status codes. @
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
Fixed a bug in http_status_to_exit_status() where invalid HTTP status codes (< 100 or >= 600) incorrectly returned SUCCESS instead of ERROR.
Changes
Test Coverage
Added comprehensive test suite ( est_status_edge_cases.py) covering:
All existing tests pass.
Motivation
The previous implementation had a catch-all else clause that returned SUCCESS for any status code not explicitly handled, which could mask errors from malformed responses or non-standard status codes.