Skip to content

[ci][doc] Check links to files on master offline; fix broken doc links - #66626

Merged
elliot-barn merged 2 commits into
masterfrom
djs-261001-ray-repo-link-check
Oct 1, 2026
Merged

elliot-barn merged 2 commits into
masterfrom
djs-261001-ray-repo-link-check

Conversation

@dstrodtman

Copy link
Copy Markdown
Contributor

Description

Docs, READMEs and docstrings often link to a file in this repo by its GitHub URL, such as https://github.com/ray-project/ray/blob/master/<path>. GitHub doesn't redirect those URLs when a file moves or is deleted. It doesn't resolve them through symlinked directories either, so blob/master/python/ray/rllib/... returns 404 today. Ten such links are broken on master. Six are in RLlib READMEs and example docstrings that the Sphinx linkcheck never sees.

A network check can't catch this on a pull request, because a PR's new links point at paths that don't exist on master until the PR merges. But a link like this is correct exactly when its path exists in the tree being committed, so it can be checked offline and the check can block.

This PR makes three changes.

1. ci/lint/check_ray_repo_links.py

  • Finds every github.com/ray-project/ray/{blob,tree,raw}/master/<path> and raw.githubusercontent.com/ray-project/ray/[refs/heads/]master/<path> link in tracked text files.
  • Checks each path against git ls-files and fails on any path that doesn't exist.
  • Ignores pinned SHAs, tags, other branches, and #L42 line anchors.
  • Runs in about 0.8s with no network.

It runs in the lint-small-prose matrix (always), not in pre_commit. A prose-only change can fail it: renaming or deleting a doc file breaks links to it elsewhere, and pre_commit is filtered out of prose-only PRs. It also scans the whole tree rather than only changed files, for the same reason. It's also registered as a local pre-commit hook.

2. Link fixes. These cover everything the new check reports on master, plus the Ray-owned links that the postmerge doc: linkcheck step confirms broken, wherever a replacement checked out.

  • RLlib READMEs, rl-modules.md and the custom_experiment.py docstring now point at current paths. The DDPPO and APEX entries for removed algorithms are dropped.
  • tune-distributed.rst now points at python/ray/tune/examples/tune-default.yaml.
  • src/ray/.cursor/BUGBOT.md now points at rpc-fault-tolerance.md, the MyST version of the page.
  • Starlette and Uvicorn moved their docs to starlette.dev and uvicorn.dev, which are the homepage values of their GitHub repos. The old hosts no longer answer.
  • The Arch Wiki, Vale, and Databricks statement execution API links point at those sites' current URLs.

3. linkcheck_report.py writes a linkcheck-report.json artifact instead of posting to Slack.

  • The step's container already mounts the agent's artifact directory at /artifact-mount.
  • The DOCS_LINKCHECK_SLACK_WEBHOOK env var it read was never provisioned, so today every run ends with "not set; skipping Slack alert" and nobody sees the result.
  • A scheduled job maintained by the docs team now reads the result through the Buildkite API and posts the digest, so no Slack credential has to enter this repo's CI secrets. That job also parses the printed lines when the artifact is missing, so the printed format is unchanged.

Related issues

Related to #66096, which moves rllib/ under python/ray/ and rewrites the RLlib links for the new paths.

  • This PR's RLlib edits make the same choices as that PR, but use the current master paths. Whichever merges second has a small conflict on those lines.
  • Once this lands, the new check covers the move itself: any /master/rllib/... link Move /rllib/ into /python/ray/ #66096 misses fails lint on that PR, not after merge.

Not a duplicate: open PR searches for "link check", "broken links", "linkcheck", and "dead links" turn up nothing in this area.

Additional information

Left out on purpose:

  • The torch Stream link that linkcheck reports comes from intersphinx. conf.py pins the torch inventory to 2.9 but keeps base_url at docs/stable/, and stable has since renamed that page. The fix is a deliberate conf.py decision, so it isn't bundled here.
  • 19 of the confirmed-broken links live in the externally fetched _collections/ template content, which is fixed in the templates repo, not here.

Testing:

  • python ci/lint/check_ray_repo_links.py passes on this branch and reports the 10 links above on master.
  • To confirm it catches a move, I removed python/ray/tune/examples/tune-default.yaml from a scratch index (GIT_INDEX_FILE). The check then reported the tune-distributed.rst link and exited 1.
  • bash ci/lint/lint.sh ray_repo_links passes.
  • pre-commit run --files <changed files> passes, including the new hook, ruff, black, pydoclint and docstyle.
  • I ran linkcheck_report.main() against a synthetic output.json with LINKCHECK_RECHECK_COOLDOWN=0. One dead and one live URL produced a single confirmed entry in the artifact. An empty input produced an empty report.
  • Every URL this PR adds returns HTTP 200, and every anchor (#streamingresponse, #timeouts, #using-pure-asgi-middleware, #Installing_and_upgrading_packages) exists on its target page.

Review note: .buildkite/lint.rayci.yml and ci/lint/lint.sh are shared CI surfaces, so this wants a ray-ci review. The lint steps don't carry oss, so the check also runs in downstream forks that reuse this .buildkite/ tree, against the fork's own tree.

AI assistance (Claude Code) was used to write this change. I reviewed every changed line and ran the commands above.

Add ci/lint/check_ray_repo_links.py, which resolves every
github.com/ray-project/ray/{blob,tree,raw}/master/<path> and
raw.githubusercontent.com/ray-project/ray/master/<path> link in the tree
against `git ls-files`. It needs no network, so it can block: a link is
correct exactly when its path exists in the tree being committed. It runs
in the prose lint matrix, because renaming a doc file breaks links to it
elsewhere, and as a local pre-commit hook.

Fix the 10 links it reports on master, and the 12 external doc links that
the postmerge linkcheck confirms broken and that resolve to a verified
replacement.

Make linkcheck_report.py write its confirmed list to a
linkcheck-report.json build artifact instead of posting to Slack. The
webhook it read was never provisioned, and an external job now reads the
result through the Buildkite API.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Douglas Strodtman <[email protected]>
@dstrodtman
dstrodtman marked this pull request as ready for review October 1, 2026 13:50
@dstrodtman
dstrodtman requested review from a team as code owners October 1, 2026 13:50

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request introduces a new lint check (check_ray_repo_links.py) to verify that GitHub links pointing to Ray's master branch resolve to existing files in the repository, integrating it into pre-commit and Buildkite workflows. It also updates the Sphinx linkcheck reporting tool to output a build artifact rather than posting directly to Slack, and fixes several broken links across the documentation. The review feedback highlights a critical bug in parsing NUL-terminated git grep output, suggests improvements to handle templated URLs containing curly braces, and recommends falling back to the original Sphinx error code in the linkcheck report if a re-check code is missing.

Comment thread ci/lint/check_ray_repo_links.py Outdated
Comment on lines +80 to +83
for record in result.stdout.decode("utf-8", "replace").splitlines():
# With -z, the separators after the file name and line number are NULs.
path, lineno, text = record.split("\0", 2)
lines.append((path, int(lineno), 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.

high

Using splitlines() on the output of git grep -z is incorrect because -z causes git grep to use NUL bytes (\0) as the record terminator instead of newlines. As a result, splitlines() will not split the matches correctly, and record.split("\0", 2) will swallow all subsequent matches into the text field of the first match. This leads to incorrect filename and line number reporting for all subsequent broken links.

Instead, the entire output should be split by \0 and parsed in chunks of 3 elements (file, line number, and content).

Suggested change
for record in result.stdout.decode("utf-8", "replace").splitlines():
# With -z, the separators after the file name and line number are NULs.
path, lineno, text = record.split("\0", 2)
lines.append((path, int(lineno), text))
out = result.stdout.decode("utf-8", "replace")
if out:
parts = out.split("\0")
if parts and not parts[-1]:
parts.pop()
for i in range(0, len(parts), 3):
if i + 2 < len(parts):
lines.append((parts[i], int(parts[i+1]), parts[i+2]))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for flagging this line. The framing diagnosis doesn't hold, though: git grep -z only swaps the separators after the file name and line number for NULs, and each record still ends in a newline. Across this repo the output is 553 records with exactly 1,106 NULs, two per record, and the check reports the correct file:line for every broken link it finds. The line did have a related bug: splitlines() also breaks on form feeds and Unicode line separators inside a matched line, which would crash the unpacking. Fixed in 93af2f1 by splitting on "\n" only. I tested it against a line containing \x0c.

Comment thread ci/lint/check_ray_repo_links.py Outdated
r"/(?:refs/heads/)?master/"
# A path runs until whitespace or a character that ends a URL in Markdown,
# rST, HTML, Python strings, or JSON-encoded notebook text.
r"([^\s\"'`()<>\[\]{}|\\^]+)"

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.

medium

Allow { and } in the captured path regex so that templated URLs containing curly braces can be fully matched and subsequently filtered out as templates, rather than being truncated and incorrectly validated as directories.

Suggested change
r"([^\s\"'`()<>\[\]{}|\\^]+)"
r"([^\s\"'`()<>\[\]|\\^]+)"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Applied in 93af2f1, together with the TEMPLATE_CHARS change below. No current link has a brace, but a path like data_{suffix}.py would have been cut off at the brace and reported as missing.

Comment thread ci/lint/check_ray_repo_links.py Outdated

# Characters that mark a templated path, such as an f-string or a placeholder,
# rather than a literal one.
TEMPLATE_CHARS = set("$*")

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.

medium

Add { and } to TEMPLATE_CHARS to ensure that captured paths containing curly braces are recognized as templates and skipped during validation.

Suggested change
TEMPLATE_CHARS = set("$*")
TEMPLATE_CHARS = set("$*{}")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Applied in 93af2f1.

report = {
"confirmed": [
{
"code": record.get("recheck_code", "ERR"),

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.

medium

If recheck_code is not present in the record, defaulting to "ERR" discards the original Sphinx error code (such as 404 or 500). It is safer to fall back to the original code field from Sphinx, matching the previous behavior of the script.

Suggested change
"code": record.get("recheck_code", "ERR"),
"code": record.get("recheck_code", record.get("code", "ERR")),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not changing this one. confirm() sets recheck_code on every record before it adds that record to confirmed, so the fallback can't be reached for anything passed to write_report.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 047b2a6. Configure here.

Comment thread ci/ray_ci/doc/linkcheck_report.py Resolved
- linkcheck_report.py: when Sphinx wrote no output.json, write no report
  and don't print the all-clear line, so a consumer can tell a run that
  produced nothing apart from a clean one.
- check_ray_repo_links.py: split git grep -z output on "\n" only.
  splitlines() also breaks on form feeds and Unicode line separators
  inside a matched line, which would crash the record unpacking.
- check_ray_repo_links.py: capture braces in the path and treat them as
  template markers, so a templated path is skipped whole instead of being
  cut off at the brace.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Douglas Strodtman <[email protected]>
@dstrodtman dstrodtman added the go add ONLY when ready to merge, run all tests label Oct 1, 2026
@elliot-barn
elliot-barn merged commit ca6fe54 into master Oct 1, 2026
5 of 7 checks passed
@elliot-barn
elliot-barn deleted the djs-261001-ray-repo-link-check branch October 1, 2026 16:13
elliot-barn added a commit to pseudo-rnd-thoughts/ray that referenced this pull request Oct 2, 2026
…ython-ray

Resolves conflicts with ray-project#66626 (offline link check + doc link fixes) in
the appo/dqn/ppo READMEs, examples/ray_tune/custom_experiment.py and
doc/source/rllib/rl-modules.md. "Fix links" (9127161) already applied
the same link fixes on top of the moved paths, so this branch's side is
kept. ci/lint/check_ray_repo_links.py passes on the merged tree.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Signed-off-by: elliot-barn <[email protected]>
nadongjun pushed a commit to nadongjun/ray that referenced this pull request Oct 6, 2026
ray-project#66626)

## Description

Docs, READMEs and docstrings often link to a file in this repo by its
GitHub URL, such as
`https://github.com/ray-project/ray/blob/master/<path>`. GitHub doesn't
redirect those URLs when a file moves or is deleted. It doesn't resolve
them through symlinked directories either, so
`blob/master/python/ray/rllib/...` returns 404 today. Ten such links are
broken on master. Six are in RLlib READMEs and example docstrings that
the Sphinx linkcheck never sees.

A network check can't catch this on a pull request, because a PR's new
links point at paths that don't exist on master until the PR merges. But
a link like this is correct exactly when its path exists in the tree
being committed, so it can be checked offline and the check can block.

This PR makes three changes.

**1. `ci/lint/check_ray_repo_links.py`**
- Finds every `github.com/ray-project/ray/{blob,tree,raw}/master/<path>`
and
`raw.githubusercontent.com/ray-project/ray/[refs/heads/]master/<path>`
link in tracked text files.
- Checks each path against `git ls-files` and fails on any path that
doesn't exist.
- Ignores pinned SHAs, tags, other branches, and `#L42` line anchors.
- Runs in about 0.8s with no network.

It runs in the `lint-small-prose` matrix (`always`), not in
`pre_commit`. A prose-only change can fail it: renaming or deleting a
doc file breaks links to it elsewhere, and `pre_commit` is filtered out
of prose-only PRs. It also scans the whole tree rather than only changed
files, for the same reason. It's also registered as a local pre-commit
hook.

**2. Link fixes.** These cover everything the new check reports on
master, plus the Ray-owned links that the postmerge `doc: linkcheck`
step confirms broken, wherever a replacement checked out.
- RLlib READMEs, `rl-modules.md` and the `custom_experiment.py`
docstring now point at current paths. The DDPPO and APEX entries for
removed algorithms are dropped.
- `tune-distributed.rst` now points at
`python/ray/tune/examples/tune-default.yaml`.
- `src/ray/.cursor/BUGBOT.md` now points at `rpc-fault-tolerance.md`,
the MyST version of the page.
- Starlette and Uvicorn moved their docs to `starlette.dev` and
`uvicorn.dev`, which are the `homepage` values of their GitHub repos.
The old hosts no longer answer.
- The Arch Wiki, Vale, and Databricks statement execution API links
point at those sites' current URLs.

**3. `linkcheck_report.py` writes a `linkcheck-report.json` artifact
instead of posting to Slack.**
- The step's container already mounts the agent's artifact directory at
`/artifact-mount`.
- The `DOCS_LINKCHECK_SLACK_WEBHOOK` env var it read was never
provisioned, so today every run ends with "not set; skipping Slack
alert" and nobody sees the result.
- A scheduled job maintained by the docs team now reads the result
through the Buildkite API and posts the digest, so no Slack credential
has to enter this repo's CI secrets. That job also parses the printed
lines when the artifact is missing, so the printed format is unchanged.

## Related issues

Related to ray-project#66096, which moves `rllib/` under `python/ray/` and rewrites
the RLlib links for the new paths.
- This PR's RLlib edits make the same choices as that PR, but use the
current master paths. Whichever merges second has a small conflict on
those lines.
- Once this lands, the new check covers the move itself: any
`/master/rllib/...` link ray-project#66096 misses fails lint on that PR, not after
merge.

Not a duplicate: open PR searches for "link check", "broken links",
"linkcheck", and "dead links" turn up nothing in this area.

## Additional information

**Left out on purpose:**
- **The torch `Stream` link** that linkcheck reports comes from
intersphinx. `conf.py` pins the torch inventory to 2.9 but keeps
`base_url` at `docs/stable/`, and `stable` has since renamed that page.
The fix is a deliberate `conf.py` decision, so it isn't bundled here.
- **19 of the confirmed-broken links** live in the externally fetched
`_collections/` template content, which is fixed in the templates repo,
not here.

**Testing:**
- `python ci/lint/check_ray_repo_links.py` passes on this branch and
reports the 10 links above on master.
- To confirm it catches a move, I removed
`python/ray/tune/examples/tune-default.yaml` from a scratch index
(`GIT_INDEX_FILE`). The check then reported the `tune-distributed.rst`
link and exited 1.
- `bash ci/lint/lint.sh ray_repo_links` passes.
- `pre-commit run --files <changed files>` passes, including the new
hook, ruff, black, pydoclint and docstyle.
- I ran `linkcheck_report.main()` against a synthetic `output.json` with
`LINKCHECK_RECHECK_COOLDOWN=0`. One dead and one live URL produced a
single confirmed entry in the artifact. An empty input produced an empty
report.
- Every URL this PR adds returns HTTP 200, and every anchor
(`#streamingresponse`, `#timeouts`, `#using-pure-asgi-middleware`,
`#Installing_and_upgrading_packages`) exists on its target page.

**Review note:** `.buildkite/lint.rayci.yml` and `ci/lint/lint.sh` are
shared CI surfaces, so this wants a `ray-ci` review. The lint steps
don't carry `oss`, so the check also runs in downstream forks that reuse
this `.buildkite/` tree, against the fork's own tree.

AI assistance (Claude Code) was used to write this change. I reviewed
every changed line and ran the commands above.

---------

Signed-off-by: Douglas Strodtman <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

go add ONLY when ready to merge, run all tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants