fix(web): explain reader-side refusals instead of surfacing a bare HTTPError - #630
Open
Adkr1989 wants to merge 1 commit into
Open
fix(web): explain reader-side refusals instead of surfacing a bare HTTPError#630Adkr1989 wants to merge 1 commit into
Adkr1989 wants to merge 1 commit into
Conversation
…TPError r.jina.ai answers 401 when it declines to serve the caller's egress IP. The request never reaches the target page, but the caller only saw an unadorned urllib HTTPError and had no way to tell that apart from a genuinely missing page. check() is deliberately zero-overhead and always reports ok, so doctor's green light cannot warn about this either — read() is the only place the caller can learn what happened. Reinterpret 401/403/429 as a RuntimeError that names the cause and points at the alternatives, and chain the original error so the status code stays reachable. Every other status propagates untouched.
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.
Problem
On some networks
r.jina.aianswers 401 — it declines to serve the caller's egress IP. The request never reaches the target page, butWebChannel.read()let the rawurllib.error.HTTPErrorescape, so the caller saw only:That is indistinguishable from a genuinely missing page, and it points the reader at the wrong suspect (the target site) instead of the reader.
check()cannot help here: it is deliberately the zero-overhead tier-0 fallback and never probes the network, sodoctorreports the web channel as available regardless.read()is therefore the only place a caller can find out what actually happened.Change
read()reinterprets 401 / 403 / 429 as aRuntimeErrornaming the cause (reader-side refusal, usually egress-IP rate limiting or a block), noting thatdoctorstill shows the channel as green, and pointing at the alternatives.HTTPErroris chained withraise ... from e, so the status code stays reachable for anything logging the chain.No behaviour change on the success path, no new dependency,
check()still touches no network.Tests
tests/test_web_channel.pygains two parametrized cases:test_read_explains_a_reader_side_refusal— 401/403/429 raiseRuntimeError, the message carries the status code, and__cause__is the originalHTTPError.test_read_leaves_other_http_errors_untouched— 404/500/502 propagate asHTTPError.The 4 failures are pre-existing on
mainin this environment: they are symlink-creation tests that needSeCreateSymbolicLinkPrivilegeon Windows (WinError 1314), and are unrelated to this change.