Skip to content

fix(link-check): classify plain-http egress refusals and private redirects - #143

Merged
jimcadden merged 2 commits into
mainfrom
fix/link-check-egress-and-private-redirect
Nov 16, 2026
Merged

jimcadden merged 2 commits into
mainfrom
fix/link-check-egress-and-private-redirect

Conversation

@jimcadden

Copy link
Copy Markdown
Collaborator

Provenance

Fixes the two reviewer suggestions clawgenti left on the vendored copy of link-check.py in 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 plain http:// link, urllib sends an absolute-URI request to the proxy; when the gateway refuses, the refusal arrives as an ordinary HTTP 403 in the HTTPError branch of _check_once. Depending on the accept list the link was then either reported broken 403 (opening an issue) or silently treated as OK — both break the contract that egress refusals are never verified results.

After: a 403 classifies as unchecked when a proxy is configured for the URL's scheme and the response carries a gateway signature. The check runs in both HTTPError branches, before the GET fallback (it would only collect the same refusal) and before the accept list (a refusal is unverified, not OK). no_proxy hosts are honored via urllib's own env-based bypass check, and the proxy resolution mirrors urllib's (<scheme>_proxy over all_proxy, env-only like the existing proxy_env_set()).

Gateway signature: the repo cannot know the deployment gateway's exact signature, so detection is marker-based: GATEWAY_403_MARKERS (squid-style X-Squid-Error header, 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 via LINK_CHECK_GATEWAY_MARKERS (comma-separated). A marker match that is really an origin 403 degrades toward unchecked — never a false issue — which is the safe direction of the egress contract. Marker matching is restricted to http:// 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-private was reported broken

Before: a public URL redirecting to a private host raised URLError("redirect to private host …"); _classify_exception matched none of its tokens, so it fell through to Network 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 _RedirectToPrivateError that _check_once/_get_fallback turn into a success status — excluded, no finding, not retried, and the private host is still never fetched. Chosen over a new status token because extract-broken-links.sh maps unknown text statuses to error (which opens issues); unchecked would also be wrong since the link was policy-excluded, not unverified.

Contract restored

  • Egress refusals never open or auto-close issues, for both http:// and https:// links, with or without 403 in the accept list (the scanner's accept list includes 403).
  • Public-to-private redirects under --exclude-all-private are 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.
  • Markerless 403 through a proxy stays a real broken result (origin answer).
  • LINK_CHECK_GATEWAY_MARKERS env extension opts a deployment's own signature in.
  • _proxy_for_url: scheme gating (http_proxy vs https_proxy), all_proxy, and no_proxy suffix bypass.
  • End-to-end: an http:// refusal lands in the unchecked bucket (errors=0).
  • Public→private redirect under --exclude-all-private: excluded (success status) and served exactly once even with retries available.

Existing test_private_redirect_not_fetched was 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

  • The WARN-header stream nit on link-health-scanner.sh (also from repoman#24) is out of scope here and untouched.
  • standing-orders/link-health.md updated to describe both classifications and the new env knob.

Assisted-By: Claude Code

…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]>
@jimcadden
jimcadden marked this pull request as ready for review November 12, 2026 21:48
@jimcadden jimcadden added the ready-for-ai-review Request automated AI code review from clawgenti label Nov 12, 2026

@clawgenti clawgenti left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Comment thread scripts/link-check.py Outdated
# 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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 rubambiza left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Human scan. Nothing out of the ordinary. Leaving the detailed check to AI-assisted review.

@rubambiza rubambiza left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Comment thread scripts/link-check.py
return None
haystack = str(exc.headers or "").lower()
try:
body = exc.read(4096)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]>
@clawgenti clawgenti mentioned this pull request Nov 16, 2026
10 tasks
@jimcadden
jimcadden merged commit aabaf63 into main Nov 16, 2026
2 checks passed
@jimcadden
jimcadden deleted the fix/link-check-egress-and-private-redirect branch November 16, 2026 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-ai-review Request automated AI code review from clawgenti

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants