Skip to content

docs: make SKIP_URL_CHECK=1 actually bypass the gh-file-ref URL checks - #2367

Open
eastagiletracker wants to merge 1 commit into
ucb-bar:mainfrom
eastagiletracker:agile-board/docs-skip-url-check-bypass
Open

docs: make SKIP_URL_CHECK=1 actually bypass the gh-file-ref URL checks#2367
eastagiletracker wants to merge 1 commit into
ucb-bar:mainfrom
eastagiletracker:agile-board/docs-skip-url-check-bypass

Conversation

@eastagiletracker

Copy link
Copy Markdown

This PR proposes making the documentation build's SKIP_URL_CHECK=1 escape hatch actually skip the external github.com link checks, so local and offline docs builds no longer depend on network access. We include this PR work along with a full history of your repo at https://eastagiletracker.com/projects/240. You can sign in with your GitHub ID to claim ownership of the project.

What this changes

docs/conf.py defines the :gh-file-ref: role, which verifies every referenced repo path by issuing a live requests.get() to github.com while Sphinx builds the docs. SKIP_URL_CHECK=1 is documented as the way to turn those checks off for offline and local work: docs/README.md says it "lets the build continue if the custom external URL checks cannot access the network," the role prints "set the SKIP_URL_CHECK=1 environment variable to bypass URL checks," and docs/scripts/sphinx_to_starlight.py sets it (env.setdefault("SKIP_URL_CHECK", "1")) so the Starlight sync does not need the network.

The problem is that the flag is only consulted inside the ConnectionError branch. The requests.get() call is still made for every reference regardless of the flag, and a non-200 response or a read timeout still aborts the whole build via sys.exit(1) even when SKIP_URL_CHECK=1 is set. So the documented escape hatch does not actually bypass the checks: npm run build / npm run dev / the Sphinx preview still reach out to github.com once per reference and remain fragile to anything other than a clean connection failure.

Reproduction at current main

From docs/, run the Starlight-sync Sphinx build with the flag set:

SKIP_URL_CHECK=1 python -m sphinx -b html . _build/check -q

At e27c656 this still prints Testing GitHub URL https://github.com/... exists... and makes a network request for each of the :gh-file-ref: references (16 in the sources; 13 in the built pages). In a network-restricted run one of those requests timed out against github.com — exactly the situation the flag is supposed to make safe.

The fix

Guard the entire verification block behind if os.environ.get("SKIP_URL_CHECK") != "1": so the flag skips the network access completely, and drop the now-unreachable inner SKIP_URL_CHECK conditional in the ConnectionError handler. When the flag is unset the behavior is byte-for-byte unchanged, so the dead-link validation your CI relies on (make -C docs html, which does not set the flag) still runs and still fails on a genuinely missing path.

Verification

With the change, the same command above makes zero requests to github.com and completes without touching the network, while an unset flag still performs the check and still exits non-zero on a dead link. I confirmed both directions with a focused check that drives the role directly: with SKIP_URL_CHECK=1 it returns the reference node without calling requests.get, and with the flag unset it performs the request. The Sphinx build was run before and after the change with no new failures (the flag-set build went from 13 network checks to zero; the flag-unset verification path is byte-for-byte unchanged).

Backward compatibility

The change is opt-in and additive: only the SKIP_URL_CHECK=1 code path is affected, and only to match its already-documented contract. Builds that do not set the variable (including CI) keep validating links exactly as before.

How this was managed

This work was tracked on a live board that mirrors this repository's history, imported from your own issues and pull requests (2,286 stories and 26 labels). The specific item for this change is at https://eastagiletracker.com/projects/240/stories/126308, and the full board is at https://eastagiletracker.com/projects/240.

board

If you'd rather not receive contributions like this, reply no-more-prs on this pull request and we won't open any further ones on your repositories.


Lawrence W. Sinclair
CEO / East Agile
linkedin.com/in/lwsinclair/
eastagile.com

The :gh-file-ref: role consulted SKIP_URL_CHECK only inside the
ConnectionError branch, so a live requests.get() to github.com was
still issued for every reference and a non-200 response or a read
timeout aborted the whole build via sys.exit(1) even when the flag
was set. This defeats the documented purpose of the variable (offline
and local builds such as the Starlight sync, which sets it) and makes
those builds depend on the network.

Guard the entire verification on SKIP_URL_CHECK so the flag bypasses
the check as documented. When it is unset the behavior is unchanged,
so the dead-link validation run by `make -C docs html` in CI is
preserved.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant