Repository navigation
fix: Preserve HTTP errors for malformed response bodies - #114
Open
emmy-devop wants to merge 1 commit into
Open
emmy-devop wants to merge 1 commit into
emmy-devop wants to merge 1 commit into
Conversation
This branch has not been deployed
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.
Requested by @drafty
🔴 Review tier: HIGH — human review required
maintriggers version/release automation and PyPI publication. This PR does not merge, tag, publish, or change workflows.What / why
A failed request can return a JSON string, plain text, HTML, or malformed JSON instead of the expected error object. Dictionary access (or deserialization before error translation) then raises
AttributeError/JSONDecodeError, hiding the real HTTP failure.RateLimitExceededError, code429000), rather than trusting a bodystatus_codeor defaulting to 500.400000..599999, including429001concurrency errors and unknown subcodes. Reject strings, booleans, floats, containers, nulls, and out-of-range codes without coercion. Valid application codes still take precedence, while the original transport status remains onerror.response.status_code.Retry-After, and retain the original HTTP exception context.No limiter, retry policy, consumer dependency, workflow, version, changelog, or feature-document changes.
How tested
Python 3.11.2 with the repository's frozen development dependencies (
uv sync --frozen). Task runner unavailable locally; executed the Taskfile's test/coverage steps directly.coverage run -m pytest --junitxml=report.xml: 405 passed, including 273 new regression cases.coverage report,coverage xml,coverage html -d coverage-report: passed; total coverage 92%,errors.py100%.ruff check asknews_sdk tests/test_errors.py: passed.ruff format --check tests/test_errors.py: passed.mypy asknews_sdk/errors.py asknews_sdk/response.py: passed.uv build --wheel: passed; build only, no upload.git diff --checkandgitlint --commits HEAD^..HEAD: passed.AttributeError/JSONDecodeError, and pass with this change.Risk / follow-up / rollback
fix:subject for the squash/merge so release automation selects a patch release.Retry-Afterdoes not add automatic retries.