You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
gate: check the job token reads the Environment over GraphQL #92
Follow-up from the #85 security quick check (#85 (comment), note n2).
The gate's guard falls back to GraphQL when the REST read of the Environment hits a rate limit or a 5xx. GitHub's docs do not say which permission the job's GITHUB_TOKEN needs to read a repository Environment over GraphQL. The gate job grants contents, pull-requests and actions read, not deployments.
If the token cannot read it, the fallback never fires and the gate behaves like plain "post nothing when the Environment cannot be read" (still safe, but the comment-spam case posts nothing more often).
To do: in a scratch repository, run the gate workflow with its declared permissions and query repository.environment(name:) over GraphQL. Record yes/no. If no, either add deployments: read (check it gives nothing else) or remove the fallback and its README text.
Answer: yes. The job's GITHUB_TOKEN with exactly the gate job's declared permissions (contents: read, pull-requests: read, actions: read; no deployments) reads a repository Environment over GraphQL. deployments: read is not needed.
How: a temporary workflow on a scratch branch of this repository (triggered only by push to that branch, job permissions copied from the gate job, no environment: key) ran the guard's own query, repository(owner, name) { environment(name:) { name } }, with gh api graphql and the job token. It printed only the result shape. The gate's Environment head-gate does not exist in this repository, so the step also asked for fork-push, an Environment that does exist. Without that second name, a missing Environment would look the same as one the token may not read.
The "Set up job" log of the first run lists the token's permissions as Actions, Contents, Metadata, PullRequests: read. So the GraphQL fallback in the guard can fire with the permissions as declared. A missing Environment still gives NOT_FOUND, which the guard reads as "not seen" (False). The scratch branch is deleted.
Follow-up: a README-only PR that records this result.
Activity
Scratch (#92): same probe with deployments: read added
scuttletoby commentedon Nov 21, 2026
Answer: yes. The job's
GITHUB_TOKENwith exactly the gate job's declared permissions (contents: read,pull-requests: read,actions: read; nodeployments) reads a repository Environment over GraphQL.deployments: readis not needed.How: a temporary workflow on a scratch branch of this repository (triggered only by
pushto that branch, job permissions copied from the gate job, noenvironment:key) ran the guard's own query,repository(owner, name) { environment(name:) { name } }, withgh api graphqland the job token. It printed only the result shape. The gate's Environmenthead-gatedoes not exist in this repository, so the step also asked forfork-push, an Environment that does exist. Without that second name, a missing Environment would look the same as one the token may not read.head-gatefork-pushnull,NOT_FOUND"Could not resolve to an Environment with the name head-gate.", exit 1{"name":"fork-push"}, exit 0deployments: readThe "Set up job" log of the first run lists the token's permissions as Actions, Contents, Metadata, PullRequests: read. So the GraphQL fallback in the guard can fire with the permissions as declared. A missing Environment still gives
NOT_FOUND, which the guard reads as "not seen" (False). The scratch branch is deleted.Follow-up: a README-only PR that records this result.
🤖 Generated with Claude Code