Repository navigation
fix(link-check): classify plain-http egress refusals and private redirects - #143
Conversation
…rects Reviewer suggestions from rossoctl/repoman#24 (clawgenti), fixed at the source per the vendoring topology: 1. Plain-http egress refusals were reported broken. Egress-refusal detection only matched the CONNECT-tunnel failure text, which fires for https:// URLs only. For http:// links urllib sends an absolute-URI request to the proxy, and the gateway's refusal arrives as an ordinary 403 in the HTTPError branch: reported broken 403 (or silently accepted when 403 is in the accept list), breaking the contract that egress refusals never open issues. A 403 now classifies as unchecked when a proxy is configured for the URL's scheme and the response carries a gateway signature (GATEWAY_403_MARKERS, extendable via LINK_CHECK_GATEWAY_MARKERS), before the GET fallback and the accept list. no_proxy hosts are honored via urllib's own env bypass check. 2. A public URL redirecting to a private host under --exclude-all-private raised URLError('redirect to private host'), which _classify_exception mapped to Network error: retried, then reported broken. lychee excludes such links. The redirect handler now raises a dedicated _RedirectToPrivateError that the check paths turn into a success status (excluded, no finding, not retried). Tests: http 403 with gateway signature is unchecked (with and without 403 in the accept list); a markerless 403 through a proxy stays broken; LINK_CHECK_GATEWAY_MARKERS extension; _proxy_for_url scheme and no_proxy resolution; an http refusal lands in the unchecked bucket, not errors; a private redirect is excluded and served exactly once even with retries available. Signed-off-by: Jim Cadden <[email protected]> Assisted-By: Claude (Anthropic AI) <[email protected]>
clawgenti
left a comment
There was a problem hiding this comment.
Summary
This is a well-scoped fix. Plain-http egress refusals are classified as unchecked only when a proxy covers the URL's scheme and the 403 carries a gateway signature. Private redirects under --exclude-all-private are now excluded rather than retried and reported, and there are good positive and negative tests. One suggestion on the breadth of the default markers. No blocking issues.
Author: jimcadden (COLLABORATOR — maintainer)
Areas reviewed: Python (link-check.py and tests), Docs (standing order)
Agent/IDE config (.claude/.vscode): none
Commits: 1 commit, all signed-off: yes
CI status: PR checks pass (DCO, PR title, project automation). The push-triggered tests.yml run on this head failed, and it is also failing on main since c138e5f, so that failure predates this PR.
Verified by: python tests/test-link-check.py on head (58 tests OK) and the CI shell test list. The only local failure is test-extract-broken-links.sh Test 11, a sandbox /dev/stdin limitation that is unrelated to this PR.
Generated by RepoMan github-pr-review@235a7f7 (https://github.com/rossoctl/agent-skills/blob/235a7f7620139ee3e4ab0872b8439591fe52e8c1/skills/github-pr-review/SKILL.md).
| # LINK_CHECK_GATEWAY_MARKERS (comma-separated substrings). | ||
| GATEWAY_403_MARKERS = ( | ||
| "x-squid-error", # squid ACL-denial header | ||
| "access denied", # common ACL-denial header/body text |
There was a problem hiding this comment.
suggestion: "access denied" (and "egress" on line 612) are broad defaults. CDN origin 403 pages commonly say "Access Denied" (Akamai's standard 403 body), and a gateway that allows the host relays that page unchanged. So an origin 403 on an allowlisted plain-http host turns into unchecked. That is the safe direction per the docstring, but it silently hides real results. Consider keeping only the gateway-specific defaults (x-squid-error, the allowlist phrases) and letting deployments opt broader phrases in through LINK_CHECK_GATEWAY_MARKERS.
There was a problem hiding this comment.
Applied in daa5a2f: dropped the broad "access denied" and "egress" defaults, so the remaining GATEWAY_403_MARKERS are gateway-specific only (X-Squid-Error header, "blocked by your network/organization/policy" wording, and the allowlist phrases). Broader phrases are opt-in via LINK_CHECK_GATEWAY_MARKERS as before. Added a regression test that a markerless CDN-style "Access Denied" 403 relayed through a proxy stays a real broken result, and that the phrase still classifies as a refusal when opted in through the env knob.
Assisted-By: Claude Code
rubambiza
left a comment
There was a problem hiding this comment.
Human scan. Nothing out of the ordinary. Leaving the detailed check to AI-assisted review.
rubambiza
left a comment
There was a problem hiding this comment.
Summary
Clean, well-tested fix from a maintainer. Classifies plain-http:// egress-gateway 403 refusals as unchecked (not broken) and treats --exclude-all-private public→private redirects as excluded (lychee parity), fixing the two clawgenti suggestions carried over from the vendored copy in rossoctl/repoman#24.
Verified independently (not just from the description): _RedirectToPrivateError subclasses URLError (not HTTPError), so it bypasses the HTTPError handler and resolves to success/None; the retry loop treats None and unchecked as terminal (not retried); refusal detection is gated on http:// + a proxy for the scheme, and a markerless origin 403 stays broken (explicitly tested) — the classifier degrades toward unchecked, never toward a false "OK". The design matches the real consumer: extract-broken-links.sh maps unknown text statuses to error and handles unchecked before the catch-all. 58 Python tests pass locally; py_compile clean; docs updated accurately.
Author: jimcadden (MEMBER — maintainer)
Areas reviewed: Python, Tests, Docs, Security (egress false-positive surface)
Agent/IDE config (.claude/.vscode): none
Commits: 1 commit, all signed-off: yes
CI status: passing (DCO, pr-title; repo runs no test/lint job on PRs — suite verified locally)
| return None | ||
| haystack = str(exc.headers or "").lower() | ||
| try: | ||
| body = exc.read(4096) |
There was a problem hiding this comment.
nit (non-blocking): exc.read(4096) caps the gateway-signature search at 4 KB of body. A squid/ACL denial page is well under that, so this is fine in practice — just noting the bound is silent. A one-word "intentional" note (headers are already searched in full) would stop a future reader widening it expecting unbounded matching.
There was a problem hiding this comment.
Noted and addressed in daa5a2f: added a comment at the exc.read(4096) call stating the 4 KB cap is intentional (gateway denial pages are well under it) and that the header block is already searched in full, so a future reader will not widen it expecting unbounded matching.
Assisted-By: Claude Code
…ic signatures Review feedback on #143 (clawgenti): the 'access denied' and 'egress' default markers are broad enough that a CDN origin 403 relayed through the gateway (Akamai's standard 403 body says 'Access Denied') would classify as unchecked, silently hiding a real result on an allowlisted plain-http host. Remove both from GATEWAY_403_MARKERS, keeping only the gateway-specific defaults (X-Squid-Error header, 'blocked by your network/organization/policy' wording, allowlist phrases); deployments opt broader phrases in via LINK_CHECK_GATEWAY_MARKERS as before. Also note per rubambiza's review that the 4 KB body cap in _egress_refusal_403 is intentional (gateway denial pages are small; headers are searched in full), so a future reader doesn't widen it expecting unbounded matching. Tests: add a regression test that a markerless CDN-style 'Access Denied' 403 through a proxy stays a real broken result, and that the phrase still classifies as a refusal when opted in via LINK_CHECK_GATEWAY_MARKERS. standing-orders/link-health.md updated to match the narrowed defaults. Signed-off-by: Jim Cadden <[email protected]> Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Jim Cadden <[email protected]>
Provenance
Fixes the two reviewer suggestions clawgenti left on the vendored copy of
link-check.pyin rossoctl/repoman#24 (inline comments at ~line 581 and ~line 622 of the vendored file). Per the repo topology the engine lives here, so both are fixed at the source; repoman will pick them up on the next vendor refresh.Fix 1 — plain-http egress refusals were reported broken (or silently OK)
Before: egress-refusal detection only matched the CONNECT-tunnel failure text, and that path only fires for
https://URLs. For a plainhttp://link, urllib sends an absolute-URI request to the proxy; when the gateway refuses, the refusal arrives as an ordinary HTTP 403 in theHTTPErrorbranch of_check_once. Depending on the accept list the link was then either reported broken403(opening an issue) or silently treated as OK — both break the contract that egress refusals are never verified results.After: a 403 classifies as
uncheckedwhen a proxy is configured for the URL's scheme and the response carries a gateway signature. The check runs in bothHTTPErrorbranches, before the GET fallback (it would only collect the same refusal) and before the accept list (a refusal is unverified, not OK).no_proxyhosts are honored via urllib's own env-based bypass check, and the proxy resolution mirrors urllib's (<scheme>_proxyoverall_proxy, env-only like the existingproxy_env_set()).Gateway signature: the repo cannot know the deployment gateway's exact signature, so detection is marker-based:
GATEWAY_403_MARKERS(squid-styleX-Squid-Errorheader, ACL-denial body phrases like "access denied" / "blocked by", allowlist wording, "egress") matched case-insensitively against the response header block and body, extendable without code changes viaLINK_CHECK_GATEWAY_MARKERS(comma-separated). A marker match that is really an origin 403 degrades towardunchecked— never a false issue — which is the safe direction of the egress contract. Marker matching is restricted tohttp://URLs:https://refusals are already caught by the CONNECT path, and applying body markers to tunneled origin responses would risk masking genuine findings.Fix 2 — redirect-to-private under
--exclude-all-privatewas reported brokenBefore: a public URL redirecting to a private host raised
URLError("redirect to private host …");_classify_exceptionmatched none of its tokens, so it fell through toNetwork error, was retried, and was reported broken.After (lychee parity): lychee excludes such links rather than flagging them. The redirect handler now raises a dedicated
_RedirectToPrivateErrorthat_check_once/_get_fallbackturn into a success status — excluded, no finding, not retried, and the private host is still never fetched. Chosen over a new status token becauseextract-broken-links.shmaps unknown text statuses toerror(which opens issues);uncheckedwould also be wrong since the link was policy-excluded, not unverified.Contract restored
http://andhttps://links, with or without 403 in the accept list (the scanner's accept list includes 403).--exclude-all-privateare excluded, matching lychee, and can no longer open issues.Test coverage added (
tests/test-link-check.py)http://URL refused by the proxy with a gateway-signature 403 →unchecked, not broken — with and without 403 in the accept list.LINK_CHECK_GATEWAY_MARKERSenv extension opts a deployment's own signature in._proxy_for_url: scheme gating (http_proxyvshttps_proxy),all_proxy, andno_proxysuffix bypass.http://refusal lands in theuncheckedbucket (errors=0).--exclude-all-private: excluded (success status) and served exactly once even with retries available.Existing
test_private_redirect_not_fetchedwas updated to the new excluded contract (the not-fetched guarantee is preserved; the reporting changes from broken to excluded). All 58 python tests and the full 39-script CI shell suite pass locally.Behavior documented rather than changed
link-health-scanner.sh(also from repoman#24) is out of scope here and untouched.standing-orders/link-health.mdupdated to describe both classifications and the new env knob.Assisted-By: Claude Code