Skip to content

fix(pii-gate): run under restrictive default token perms (contents-scoped Compare API)#63

Merged
saadqbal merged 1 commit into
mainfrom
fix/pii-gate-token-perms
Jun 18, 2026
Merged

fix(pii-gate): run under restrictive default token perms (contents-scoped Compare API)#63
saadqbal merged 1 commit into
mainfrom
fix/pii-gate-token-perms

Conversation

@saadqbal

@saadqbal saadqbal commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Problem

After publishing `public-pii-gate.yml` to main (#60), the Public PII gate still failed at startup with 0 jobs on every PR in adopting repos (cli, data-ingestors).

Root cause: the reusable workflow declared `permissions: { contents: read, pull-requests: read }`, but those repos' default workflow token permission is "read" (grants `contents`/`packages` read; `pull-requests: none`). A minimal caller (`uses:` + `secrets: inherit`, no `permissions:` block) therefore cannot grant `pull-requests`, so the called workflow's request exceeds the caller's ceiling → startup failure, no jobs.

Fix

Make the reusable workflow self-sufficient under the restrictive default so callers stay trivial (no per-repo `permissions:` block, no recurring footgun):

  • Read commit messages via the Compare API (`repos/{repo}/compare/{base}...{head}`), which is contents-scoped, instead of `gh pr view --json commits` (pull-requests-scoped).
  • Request only `permissions: contents: read` (least privilege).

Title/body/labels already come from the event payload (no API). Full scan coverage (title + body + commit messages) is preserved.

Verification

On a test PR in tracebloc/cli with an unmodified minimal caller pointed at this branch, the gate ran green (jobs executed, no startup failure) — run 27748465192. Before the fix, identical minimal callers @main produced 0-job startup failures.

Tracking: #62


Note

Low Risk
CI-only permission and API change for PR text scanning; same haystack sources with a documented 250-commit Compare API cap.

Overview
Fixes reusable Public PII gate workflows that failed at startup with 0 jobs when called from repos whose default GITHUB_TOKEN only grants contents: read (no pull-requests).

The workflow now requests permissions: contents: read only (drops pull-requests: read) and loads commit messages via the Compare API (repos/.../compare/{base}...{head}) using PR_BASE_SHA / PR_HEAD_SHA from the event, instead of gh pr view --json commits. PR title, body, and labels still come from the payload; scan coverage is unchanged.

Header comments document why pull-requests must not be requested and the 250-commit Compare API limit.

Reviewed by Cursor Bugbot for commit 5fad0d9. Bugbot is set up for automated code reviews on this repo. Configure here.

@saadqbal saadqbal self-assigned this Jun 18, 2026
@LukasWodka

Copy link
Copy Markdown
Contributor

👋 Heads-up — Code review queue is at 32 / 30

Above the WIP limit. The team convention is to review existing PRs before opening new work.

Open PRs currently in Code review (oldest first):

Pull from review before opening new work. (This is a nudge from the kanban WIP check, not a block.)

@saadqbal

Copy link
Copy Markdown
Contributor Author

Verified green on a test PR in tracebloc/cli with an unmodified minimal caller (run 27748465192) — jobs run, no startup failure; before the fix the same minimal caller @main gave 0-job startup failures. Needs one approving review from a non-author (org ruleset on main blocks self-approval, admin-merge, and direct push). Once approved I'll squash-merge and re-verify on main. Tracking #62.

@saadqbal saadqbal merged commit 54b1817 into main Jun 18, 2026
5 checks passed
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.

3 participants