Skip to content

Make backlog_metrics.py's Attention Read Work Under a Fine-Grained Token, Which Cannot Read checkSuites or Check Contexts #4584

Done

Description

@ptr727

Problem

scripts/backlog_metrics.py --format json exits 1 whenever it runs under a fine-grained personal access token and the fleet holds a private repository with an open pull request. The attention read fails as a whole, the JSON is still printed, and the run reports failure. HomeAutomation-Config's weekly fleet report runs under such a token. So since #4392 reached main, every weekly mail reads "FAILED during the metrics run", with the note "Attention lists were unavailable".

Cause

ATTENTION_QUERY asks for two fields on each open pull request's head commit that a fine-grained token cannot read on a private repository:

  • checkSuites(last: 50) { ... }
  • statusCheckRollup { contexts(...) { ... } }

Fine-grained tokens offer no Checks permission, so no permission the maintainer can grant opens these fields. GitHub answers each node with an error of this shape:

{"type": "FORBIDDEN", "path": ["repository", "pullRequests", "nodes", <n>, "commits", "nodes", 0, "commit", "checkSuites", "nodes", <n>], "message": "Resource not accessible by personal access token"}

collect_attention raises GhError on the first such response. main() records it as attention_error, which forces a return of 1.

statusCheckRollup { state } itself is readable under the same token, and so is GET /repos/{owner}/{repo}/actions/runs?head_sha= (Actions: Read-only). HomeAutomation-Config's own scripts/fleet_attention.py reads failing pull requests that way for this reason, and it still works under the same token in the same run.

Constraint

The fleet report runs under a fine-grained token on purpose, and that is not changing. A fix that needs a classic token, or a Checks permission, does not fix it.

Possible directions

These are for the hub to decide.

  1. Read failing pull requests from statusCheckRollup { state } plus Actions runs for the head SHA, as fleet_attention.py does, and drop checkSuites and contexts from the attention query.
  2. At the least, treat a FORBIDDEN on those paths per repository as "check detail unavailable" rather than failing the whole attention read and the exit code. A per-repository note then says what was not read.

Related

Done looks like

  • backlog_metrics.py --format json, run under a fine-grained token with Actions, Contents, Issues, Pull requests, and Metadata read access, exits 0 over a fleet that includes private repositories with open pull requests, and its attention lists are populated.
  • A test covers a GraphQL response with FORBIDDEN errors on check paths.

Activity

  1. added
    bug
    script
    on Nov 30, 2026
  2. added a commit that references this issue on Nov 30, 2026
    ed0326f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugscript

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions