Repository navigation
fix: raise an informative error for a non-JSON manifest response - #268
Merged
Merged
Conversation
get_manifest() called response.json() straight after the status check, so a 200 carrying a non-JSON body (a proxy error page, an empty body) surfaced as a bare JSONDecodeError with no URL, status, or body context (oras-project#223). Catch the decode failure (ValueError, the common base of the requests, simplejson and stdlib json JSONDecodeError variants) and re-raise a ValueError that names the request, the status code, the Content-Type, and a snippet of what came back instead. Signed-off-by: Aditya <205600203+Rohilalala@users.noreply.github.com>
vsoch
approved these changes
Nov 18, 2026
vsoch
left a comment
Contributor
There was a problem hiding this comment.
This looks great! Straight forward and logical. We're good to merge.
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.
What
get_manifest()calledresponse.json()immediately after the status check, so a200carrying a non-JSON body (a reverse-proxy error page, an empty body, truncated content) surfaced as a bareJSONDecodeErrorwith no URL, status, or body — the "non-informative JSONDecodeError" in #223.Before / after
Before:
After:
The decode failure is caught as
ValueError— the common base of therequests,simplejsonand stdlibjsonJSONDecodeErrorvariants — so it also behaves onrequests < 2.27, whererequests.exceptions.JSONDecodeErrordoes not exist.Tests
oras/tests/test_provider.py::test_get_manifest_non_json_response, parametrised over both therequestsand the stdlib decode error. No live registry needed:Not fixed here
get_tags()and a couple of otherresponse.json()call sites can raise the same bare error on a non-JSON body; left out to keep this scoped to the path #223 reports.Closes #223.