Skip to content

Raise API exceptions for empty HTTP error responses - #124

Draft
Kayvan-Zahiri wants to merge 1 commit into
SiftScience:masterfrom
Kayvan-Zahiri:codex/reject-empty-http-error-responses
Draft

Kayvan-Zahiri wants to merge 1 commit into
SiftScience:masterfrom
Kayvan-Zahiri:codex/reject-empty-http-error-responses

Conversation

@Kayvan-Zahiri

Copy link
Copy Markdown

Response only checks HTTP status inside the branch that parses a nonempty response body. An empty 400/401/429/500/503 response therefore returns normally despite the constructor's documented non-2XX exception contract.

Move the existing status-validation finally outside the conditional body parsing. Preserve the existing status-error precedence over JSON parsing errors and all diagnostic fields. Empty successful responses remain valid.

Validation: five empty-error status cases fail before the fix; whitespace-error and empty-success controls retain their behavior. A further regression invokes real Client.track() with a mocked Requests session and verifies an empty 503 propagates as ApiException. All 86 unit tests pass. Full Black, isort, Flake8, MyPy (11 files), and git diff --check pass. No live fraud events, credentials, integration app, or full Python matrix were used.

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