Skip to content

fix: use two-dot diff in check_llms_txt.py's PR-added-page detection - #184

Merged
zoltan-baba merged 1 commit into
mainfrom
fix/llms-txt-check-shallow-clone-diff
Aug 14, 2026
Merged

fix: use two-dot diff in check_llms_txt.py's PR-added-page detection#184
zoltan-baba merged 1 commit into
mainfrom
fix/llms-txt-check-shallow-clone-diff

Conversation

@zoltan-baba

Copy link
Copy Markdown
Collaborator

The "pending deploy" carve-out added in #179 (skip failing the build for links to pages added in the same PR) doesn't actually work in CI, as seen in #182: a genuinely new page (managing-rde-access.mdx, matching slug in llms.txt) was still reported as a broken link.

Root cause: added_page_slugs() computes git diff --name-status origin/<base>...HEAD (three-dot), which requires Git to find a merge-base between the two refs. But actions/checkout checks out the PR's merge ref with --depth=1, and the script's own git fetch --depth=1 origin <base> is a separate shallow fetch — so the two commits share no common ancestor commit actually present in the local repo. The merge-base lookup fails, is silently swallowed by the existing except block, and new_slugs comes back empty.

Fix: use two-dot diff instead. It compares the two tree snapshots directly without needing shared ancestry, so it's unaffected by shallow-fetch depth. It's also equivalent to the three-dot result in this exact setup, since the checked-out ref is GitHub's merge commit (parents: base-tip, PR-head) — so merge-base(base, merge-commit) is trivially base-tip itself.

No behavior change for the intended case; this only fixes the CI environment where the check was silently degrading to "always treat as broken."

Test plan

  • Re-run check-llms-txt on this PR (touches scripts/check_llms_txt.py, so it triggers) and confirm it passes
  • Once merged, watch that [ER-2846] Add RDE role management docs #182 (or a similar PR adding a new page referenced in llms.txt) no longer fails this check

🤖 Generated with Claude Code

Three-dot diff needs a merge-base, which fails in CI: the checkout action
fetches the PR's merge ref shallowly (--depth=1), and the script's own
git fetch for the base ref is also shallow and separate, so the two
commits share no locally-available common ancestor. The merge-base
computation errors out, is silently swallowed, and added_page_slugs()
returns empty — so a page added in the same PR is reported as a broken
link instead of "pending deploy" (seen in #182).

Two-dot diff compares the two tree snapshots directly and needs no
shared ancestry, so it works regardless of fetch depth. It's also
equivalent to three-dot's result here, since main-tip is already a
parent of the checked-out merge commit, making the merge-base trivially
main-tip itself.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

@zoltan-baba
zoltan-baba merged commit 338b011 into main Aug 14, 2026
3 checks passed
@zoltan-baba
zoltan-baba deleted the fix/llms-txt-check-shallow-clone-diff branch August 14, 2026 12:41
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