Skip to content

fix(ci): fall back to github.token when AUTOFIX_BOT_PAT empty on fork PRs - #66562

Closed
pnascimento9596 wants to merge 1 commit into
NousResearch:mainfrom
pnascimento9596:fix/ci-detect-autofix-pat-fallback
Closed

fix(ci): fall back to github.token when AUTOFIX_BOT_PAT empty on fork PRs#66562
pnascimento9596 wants to merge 1 commit into
NousResearch:mainfrom
pnascimento9596:fix/ci-detect-autofix-pat-fallback

Conversation

@pnascimento9596

Copy link
Copy Markdown
Contributor

What does this PR do?

Restores CI for every fork PR broken since #66373 (merge 597615ade, 2026-07-17 ~20:55 UTC).

Empty secrets.AUTOFIX_BOT_PAT on fork pull_request runs is passed into detect-changes, which overrides the action default (github.token). The compare API then fails (GH_TOKEN empty), the classifier fails open (ci_review=true + all lanes), and the required CI-sensitive file review job hard-fails on the same empty PAT.

Impact first

Every external contributor PR on CI-sensitive lanes (and, via fail-open, even PRs that only touch Python/docs/etc.) is red through no fault of the author. Real test/lint/docker/js/docs lanes often go green while the required aggregate fails.

Traced chain (file:line, not paraphrase)

  1. .github/workflows/ci.yml:56github-token: ${{ secrets.AUTOFIX_BOT_PAT }} with no || github.token fallback (introduced by fix(ci): make tests, workflows, and attribution reliable under load #66373 / 597615ade).
  2. .github/actions/detect-changes/action.yml:50GH_TOKEN: ${{ inputs.github-token }} (empty string overrides action default at lines 11–12).
  3. action.yml:72–81 — compare API retries 3×; on failure: ::warning::compare API failed after 3 attempts — failing open (all lanes run) and CHANGED="".
  4. scripts/ci/classify_changes.py:106–114 — empty file list sets all lanes true, including ci_review=true.
  5. .github/workflows/ci.yml:74,78 — lint workflow runs with ci_review: true.
  6. .github/workflows/lint.yml:174,184ci-review job runs; GH_TOKEN: ${{ secrets.AUTOFIX_BOT_PAT }} is empty → "Fetch PR labels" hard-fails after 3 retries.
  7. .github/workflows/ci.yml:160–194All required checks pass sees lint failure → red required gate.
  8. .github/workflows/ci.yml:227 — timings job also gets empty PAT (read-only API; secondary red).

Live evidence (our run + other victims)

Run Head fork Failure
29615150242 pnascimento9596 (#66475, only env_loader.pynot CI files) Detect log: GH_TOKEN: empty → fail-open → ci_review=true; CI-sensitive file review + All required checks pass red; pytest/ruff/docker/js/docs green
29616122891 mssteuer (#66550) same: CI-sensitive file review
29616879542 helix4u (#66556) same
29616948596 roycepersonalassistant same

Detect log excerpt from 29615150242:

GH_TOKEN: 
gh: To use GitHub CLI in a GitHub Actions workflow, set the GH_TOKEN environment variable.
##[warning]compare API failed after 3 attempts — failing open (all lanes run)
Changed files:
(none)
ci_review=true

Introducing change

Fix

${{ secrets.AUTOFIX_BOT_PAT || github.token }}

at:

  • ci.yml detect (root cause — stop fail-open)
  • ci.yml timings (read-only API; same empty-secret class)
  • lint.yml label fetch (hard-fail site when ci_review is true for real CI-sensitive diffs)

Comment-post steps in lint stay PAT-only (already head.repo.fork != true).

Relationship to #66559 / #66560

Related Issue

Fixes #66559

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)

How to Test / what was verified

Meta-limitation (honest): workflow file changes from a fork do not run with the modified content on pull_request — GitHub uses the base-branch workflow. So this PR's own CI will still demonstrate the bug (red on the same job) until a maintainer merges to main or re-runs from a same-repo branch. Frame that as live evidence, not a failure of this fix.

Verified here:

  1. Verbatim main-branch chain above (file:line).
  2. Expression fallback semantics: empty secret → github.token; present PAT → PAT.
  3. YAML/text edit only; no job graph changes.
  4. Victim pattern across multiple forks after the fix(ci): make tests, workflows, and attribution reliable under load #66373 merge timestamp.

Needs maintainer eyes: merge (or same-repo re-run) to confirm fork PRs that only touch Python go green without ci-reviewed.

Checklist

Code

Documentation & Housekeeping

  • N/A for docs/config/AGENTS

…ork PRs

Since NousResearch#66373 (597615a), fork pull_request runs get an empty
secrets.AUTOFIX_BOT_PAT. Passing that empty string into detect-changes
overrides the action's default github.token, so the compare API fails
and the classifier fails open (ci_review=true + all lanes). The
ci-review job then hard-fails on the same empty PAT at label fetch.

Restore the previous fail-closed-for-auth behavior by falling back to
github.token for:
- detect-changes classify input (ci.yml)
- CI timing report (ci.yml; read-only API)
- ci-review label fetch (lint.yml)

Comment-posting steps stay PAT-only (already skipped on forks).
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists sweeper:risk-automation Sweeper risk: may affect CI, automerge, label sync, or maintainer automation labels Jul 17, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for this, @pnascimento9596 — your diagnosis was spot on. The AUTOFIX_BOT_PAT being empty on fork PRs is exactly the regression from #66373, and github.token fallback on detect-changes is the right fix.

We landed the same fallback (plus the matching fix for the ci-reviewed / mcp-catalog-reviewed label gates, which had the identical fork breakage) in #66577, merged just now as SHA 1e01a4bbe7ebf35cb1452c2e0c95f886dc9c758f. It was built independently against the incoming bug report before I'd swept and found your PR — apologies for not salvaging your branch directly; your fix predated mine and reached the same conclusion. Closing as resolved on main. Appreciate you jumping on this.

@teknium1 teknium1 closed this Jul 17, 2026
@pnascimento9596

Copy link
Copy Markdown
Contributor Author

Thanks @teknium1 — confirmed #66577 covers the fork-critical paths (detect-changes + ci-reviewed / mcp-catalog-reviewed label gates). Timings still lacks the || github.token fallback but is advisory (not in all-checks-pass). Closing as superseded by the merged fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Medium — degraded but workaround exists sweeper:risk-automation Sweeper risk: may affect CI, automerge, label sync, or maintainer automation type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CI-sensitive file review fails on every fork PR: label fetch cannot read AUTOFIX_BOT_PAT

3 participants