Repository navigation
Fix /analyze-build-failure slash command never firing - #17228
Conversation
`build-failure-analysis-command.md` declared `strategy: centralized`, which tells gh-aw that a separate central dispatcher workflow owns the `issue_comment` trigger and invokes this workflow via `workflow_dispatch`. Arcade has no such dispatcher (that pattern comes from microsoft/testfx, which does have `agentic_commands.yml`), so the compiled lock file listened only on `workflow_dispatch` and nothing ever dispatched it. Result: the command workflow has never run once since it was added, while the automatic `build-failure-analysis` workflow runs normally. Commenting `/analyze-build-failure` on a PR does nothing. Dropping `strategy: centralized` makes the workflow self-contained: it now compiles to `on: issue_comment` (types: created, edited) and gh-aw generates the `pre_activation` role/command-position check itself. Because `fetch-binlog` is a dependency of `pre_activation`, it runs *before* the role check. Left unguarded on a decentralized trigger it would download hundreds of MB of Azure DevOps binlogs on every comment in the repository, and any public commenter could trigger that repeatedly. This adds a cheap `if:` pre-gate mirroring the same trusted-author predicate `pre_activation` uses, so an untrusted commenter cannot force the download at all. `pre_activation` remains the authoritative authorization check. Recompiled with gh-aw v0.77.5 to match the existing lock files. Co-authored-by: Copilot <[email protected]> Copilot-Session: e5db9021-5257-4cf5-83ba-486a3e398391
There was a problem hiding this comment.
Pull request overview
Fixes the Build Failure Analysis (command) agentic workflow so the /analyze-build-failure slash command can actually trigger in this repo by switching from a centralized-dispatcher model (which Arcade doesn’t have) to a self-contained issue_comment trigger, and adds a pre-gate to avoid expensive binlog downloads for unrelated comments.
Changes:
- Remove
strategy: centralizedfrom the gh-aw slash command frontmatter so the compiled workflow listens directly onissue_comment. - Add a job-level
if:guard tofetch-binlogto avoid downloading large Azure DevOps binlogs except for trusted authors and comments containing/analyze-build-failure. - Update the compiled lock workflow to reflect the new trigger and gating.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| .github/workflows/build-failure-analysis-command.md | Removes centralized dispatch configuration and adds a pre-gate if: to prevent expensive binlog downloads on non-command comments. |
| .github/workflows/build-failure-analysis-command.lock.yml | Regenerates the compiled workflow to trigger on issue_comment and includes the new fetch-binlog job gate and related generated condition updates. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
… binlogs The `fetch-binlog` pre-gate accepted any `author_association` of OWNER, MEMBER or COLLABORATOR. In an org-owned repository every org member reports as MEMBER regardless of the permission they hold on this repo, so a member with read-only access could still trigger a multi-hundred-MB Azure DevOps download on every comment -- the job runs before gh-aw's `pre_activation` role check, so nothing else stopped it. Keep the association test as the free first filter and add a step that resolves the commenter's actual permission via the collaborators API before the download runs. The legacy `.permission` field collapses maintain into write and triage into read, so matching `admin|write` is exactly the `roles: [admin, maintainer, write]` the command declares. Any API failure returns an error document rather than a role name and lands in the deny branch, so the gate fails closed. Verified in a fork: an admin commenter is allowed and the download runs; a commenter without write access produces the warning and the download step is skipped, leaving every downstream job inert.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Suppressed comments (3)
.github/workflows/build-failure-analysis-command.md:127
gh api repos/{owner}/{repo}/collaborators/{user}/permission --jq .permissioncan returnmaintain(andtriage) in addition toadmin|write|read. The current case statement treatsmaintainas unauthorized, which would skip the binlog download for maintainers and prevent the slash command from working for them.
perm=$(gh api "repos/${GITHUB_REPOSITORY}/collaborators/${COMMENTER}/permission" --jq '.permission' 2>/dev/null)
case "${perm}" in
admin|write)
echo "'${COMMENTER}' has '${perm}' access to ${GITHUB_REPOSITORY}; proceeding."
echo "authorized=true" >> "$GITHUB_OUTPUT"
.github/workflows/build-failure-analysis-command.lock.yml:1508
- This lock workflow is what actually runs in GitHub Actions, and the
permcheck currently only authorizesadmin|write. If the API returnsmaintain, maintainers will be denied and the command will never fetch binlogs.
perm=$(gh api "repos/${GITHUB_REPOSITORY}/collaborators/${COMMENTER}/permission" --jq '.permission' 2>/dev/null)
case "${perm}" in
admin|write)
echo "'${COMMENTER}' has '${perm}' access to ${GITHUB_REPOSITORY}; proceeding."
echo "authorized=true" >> "$GITHUB_OUTPUT"
.github/workflows/build-failure-analysis-command.md:112
- The comment says the REST
.permissionvalue collapsesmaintain -> writeandtriage -> read, but this endpoint can returnmaintain/triageexplicitly. Updating the comment will prevent future edits from reintroducing the authorization bug.
# legacy `.permission` field collapses maintain -> write and triage ->
# read, so `admin|write` is exactly "has push access". On any API failure
Matching only `admin|write` on the legacy `.permission` field assumed that field always collapses `maintain` into `write`. Read both fields the API returns and accept the union: `role_name` carries the precise role, while `permission` still reports push access for a custom org role whose `role_name` is a non-standard name. A maintainer is now authorized whichever field carries the role, and `triage`/`read`/`none` remain denied in both. Exercised against every response shape -- admin, write, maintain in either field, the `maintainer` spelling, triage (collapsed and explicit), read, none, custom role with and without push access, a 404 error document, and empty/garbage output: all authorize exactly as intended and every failure mode denies. Re-validated in a fork: admin commenter -> "has 'admin' access ...; proceeding" and the download ran; non-write commenter -> "does not have write access ... (resolved role 'read')" with the download step skipped.
|
Addressed the three suppressed comments from the latest review in 45debff. The review is right that resp=$(gh api "repos/${GITHUB_REPOSITORY}/collaborators/${COMMENTER}/permission" 2>/dev/null)
role=$(printf '%s' "${resp}" | jq -r '.role_name // empty' 2>/dev/null)
perm=$(printf '%s' "${resp}" | jq -r '.permission // empty' 2>/dev/null)
authorized=false
for r in "${role}" "${perm}"; do
case "${r}" in
admin|maintain|maintainer|write) authorized=true ;;
esac
done
Exercised against every response shape:
Re-validated in a fork on real |
Evangelink
left a comment
There was a problem hiding this comment.
Went back over this in more depth now that I've had time to verify the claims independently rather than just eyeballing the diff. The root-cause analysis holds up — I confirmed every load-bearing part of it — so this is not a re-litigation of the approval. But a few things came out of the closer read that I'd like you to follow up on, one of which I think is an actual (small) regression introduced by the last two commits.
What I verified independently
| Claim | Status |
|---|---|
| Nothing in the repo ever dispatched this workflow | ✅ A code search across dotnet/arcade returns only the two files in this PR for analyze-build-failure. No gh-aw dispatcher exists — the only workflow_call workflows are backport-base.yml, inter-branch-merge-base.yml, scheduled-action-cleanup-base.yml. |
Dropping strategy: centralized makes it self-contained |
✅ The lock now has on: issue_comment: types: [created, edited], and gh-aw emits pre_activation with check_membership (GH_AW_REQUIRED_ROLES: "admin,maintainer,write") + check_command_position. |
fetch-binlog runs before pre_activation |
✅ pre_activation.needs: fetch-binlog. The new gate is genuinely necessary, not belt-and-braces. |
| The lock is a real recompile, not hand-edited | ✅ body_hash unchanged, frontmatter_hash changed, and the frontmatter-salted heredoc markers (GH_AW_PROMPT_*, GH_AW_SAFE_OUTPUTS_CONFIG_*, GH_AW_MCP_CONFIG_*) all rotated in lockstep with byte-identical payloads. That's the signature of a genuine regeneration. |
Leftover aw_context / client_payload references are harmless |
✅ All compiler-generated fallbacks; github.event.inputs is null on issue_comment and Actions expressions tolerate null property access. |
A read-only GITHUB_TOKEN can call the collaborators endpoint |
✅ by symmetry — pre_activation has no permissions: block at all, so it inherits permissions: {} and still calls getCollaboratorPermissionLevel from there. fetch-binlog's contents: read + pull-requests: read is strictly more. |
So: the strategy: centralized removal is right, the fetch-binlog pre-gate is a real and necessary hardening, and the lock diff is clean. Left inline comments for the specifics — the one I actually care about is the role_name union in the permission check. Two broader points that don't attach to a line:
Every non-happy path is now a completely silent no-op
activation — which owns both the 👀 reaction and the "workflow run link" comment — is gated on needs.pre_activation.outputs.activated == 'true' && needs.fetch-binlog.outputs.binlog-found == 'true'. So the commenter gets zero feedback when the latest build passed, the build is still running, the head SHA moved, the base is out of scope, an API call hiccups, or the new permission check denies. The only trace is a ::warning:: buried in a job log they'd have to go hunting for.
This was latent before (the workflow never ran at all), but it becomes the dominant user experience now that the command actually fires — and "I typed the command and nothing happened" is the exact symptom this PR exists to fix. Ideally the reaction would be gated on pre_activation alone so receipt is acknowledged, with binlog-found only gating the agent. That needs the frontmatter if: to stop feeding activation, so it may be a gh-aw limitation — but it's worth a follow-up issue and at minimum a line in the workflow description.
The fork guard contradicts the stated validation
fetch-binlog is gated on github.event.repository.fork == false, but the last two commit messages say "Verified in a fork" / "Re-validated in a fork on real issue_comment runs". On a real GitHub fork this job is skipped outright and the whole chain goes inert. So either the validation repo was a copy rather than a fork, or the guard was removed locally for testing — in which case that one line is the part that was never actually exercised end to end. Worth confirming, because a mistake there disables the command permanently and silently rather than failing loudly.
Follow-up, not for this PR
fetch-binlog in build-failure-analysis-command.md and build-failure-analysis.md are near-identical copies of ~200 lines of shell (zip-bomb caps, path-traversal scanning, the ZIP64 digit-length guard, stale-SHA checks). This PR widens the divergence by adding the perm step to only one of them. There's already a .github/workflows/scripts/ folder as precedent — pulling this into a shared script or composite action would mean the next security fix lands in both places instead of one.
None of this should block merging — going from "never fires" to "fires, correctly gated" is a clear net win.
| authorized=false | ||
| for r in "${role}" "${perm}"; do | ||
| case "${r}" in | ||
| admin|maintain|maintainer|write) authorized=true ;; |
There was a problem hiding this comment.
This is the one I'd like changed back. The Copilot review comment that drove commits 2 and 3 asserted that this endpoint can return maintain/triage in .permission — that's wrong, and the code you had before it was correct.
The REST docs for GET /repos/{owner}/{repo}/collaborators/{username}/permission say:
The
permissionattribute provides the legacy base roles of admin, write, read, and none, where the maintain role is mapped to write and the triage role is mapped to read.
So the original case "$perm" in admin|write) was exactly "has push access or better", i.e. precisely roles: [admin, maintainer, write]. And the comment that got rewritten as "stale" was actually accurate.
The replacement makes the gate strictly more permissive. role_name is documented as "the name of the assigned role, including custom roles", and custom role names only have to avoid the base names read/triage/write/maintain/admin — so an org-defined custom role literally named maintainer that inherits from read now authorizes with no push access at all.
The new comment also argues against its own code: it says a custom role "reports a non-standard name in role_name while still showing its push access in permission". If permission already covers custom roles, the role_name arm adds nothing except false-positive surface.
Suggested revert:
perm=$(gh api "repos/${GITHUB_REPOSITORY}/collaborators/${COMMENTER}/permission" --jq '.permission' 2>/dev/null)
# Docs: `.permission` returns admin|write|read|none, with maintain mapped to
# write and triage mapped to read — so admin|write is exactly "has push
# access", matching `roles: [admin, maintainer, write]`. Any API failure
# yields neither value and lands in the deny branch (fail closed).
case "${perm}" in
admin|write) authorized=true ;;
*) authorized=false ;;
esacWidening a security pre-gate to defend against a failure mode the docs say doesn't exist isn't a trade I'd take.
There was a problem hiding this comment.
You are right, and my comment was self-contradictory: it claimed role_name "reports the precise role (so maintain and triage stay distinct)" and that permission alone would deny maintainers. Both cannot be true.
The REST docs settle it:
The
permissionattribute provides the legacy base roles ofadmin,write,read, andnone, where themaintainrole is mapped towriteand thetriagerole is mapped toread. Therole_nameattribute provides the name of the assigned role, including custom roles.
So .permission in {admin, write} is exactly "has push access or better" - precisely what roles: [admin, maintainer, write] describes, maintainers included. My rationale for the union was factually wrong, and it added exactly the hole you point at: a custom org role merely named like a privileged one (a custom maintainer inheriting read) would clear the gate with no push access.
Reverted to .permission only in #17240.
One nuance, since it cuts against "exactly equivalent": gh-aw's own check (v0.83.1, actions/setup/js/check_permissions_utils.cjs) prefers role_name, normalizes maintainer -> maintain, and falls back to inherited_role for custom roles. So .permission-only is a slightly stricter early-out than the pre_activation check that follows it. That is the safe direction for a pre-gate - it can cost a legitimate user a skipped download, never grant one access - so I went with your version.
One correction to the suggested snippet, found by live-testing it: gh api ... --jq '.permission' does not fail closed cleanly. On a non-2xx response gh prints the error document to stdout, and --jq does not filter it, so perm becomes a multi-line raw JSON blob that gets echoed into the workflow log. Keeping the two-step shape yields "" for any error shape:
resp=$(gh api "repos/${GITHUB_REPOSITORY}/collaborators/${COMMENTER}/permission" 2>/dev/null)
perm=$(printf '%s' "${resp}" | jq -r '.permission // empty' 2>/dev/null)
case "${perm}" in admin|write) authorized=true ;; *) authorized=false ;; esacExercised against the live API: admin -> allow; read -> deny; github-actions[bot] -> rejected before the call; empty login -> rejected; foo/../../bar -> rejected; nonexistent user -> deny ('none').
| github.event.repository.fork == false && | ||
| github.event.issue.pull_request && | ||
| contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association) && | ||
| contains(github.event.comment.body, '/analyze-build-failure') |
There was a problem hiding this comment.
contains() is a substring match anywhere in the body, whereas the authoritative check_command_position requires the command to be in a valid position. So any write-access user merely mentioning the command — "should we try /analyze-build-failure here?", or quoting this PR description — spins up a 15-minute ubuntu-latest runner that may pull up to 4 GB before pre_activation throws the result away. Combined with types: [created, edited], editing an old comment that contains the string re-triggers it too.
I would not naively swap in startsWith — gh-aw's position check is more permissive than that (leading whitespace/newlines are fine), so you'd start rejecting valid invocations. Either just be aware of the cost and leave it, or match check_command_position.cjs's semantics precisely. Worth a note either way.
There was a problem hiding this comment.
Agreed, and documented in #17240. The comment now states that contains() matches anywhere in the body while the authoritative check_command_position requires a valid position, so a write-access user merely mentioning the command - or editing an old comment that quotes it, since types: includes edited - still starts this job and pays for the download before pre_activation discards the result.
It stays a deliberate over-approximation: workflow if: expressions have no regex, and startsWith would reject the leading whitespace/newlines gh-aw accepts. It can cost a runner; it can never grant access.
| # `pre_activation` remains the authoritative role + command-position check, | ||
| # and `activation` additionally requires `binlog-found == 'true'`. | ||
| if: >- | ||
| github.event.repository.fork == false && |
There was a problem hiding this comment.
Separately from the fork-vs-validation question in my top-level comment: this clause plus the github.event.issue.pull_request one below it is now the only thing keeping plain issue comments from activating the workflow. gh-aw emits no issue.pull_request filter of its own despite events: [pull_request_comment] — I checked the generated lock. It degrades safely (repos/.../pulls/<issue#> 404s and hits emit_none), but the PR-only scoping is a hand-maintained property here rather than a compiler-enforced one, and that's not obvious from reading the file. Worth calling out in the comment block above.
There was a problem hiding this comment.
Correct - and I verified it in the generated lock: gh-aw emits no PR-only filter of its own despite events: [pull_request_comment], so the scoping really is a property of this hand-written expression rather than something the compiler enforces.
Documented in #17240, including that it degrades safely without the clause (repos/.../pulls/<issue#> 404s and the script emits no binlog) but would pay for a runner first.
| # `author_association` in the job-level `if:` cannot tell an org member | ||
| # with read-only access apart from a maintainer, so resolve the real | ||
| # repository permission here — before any download — and match it against | ||
| # the same `roles: [admin, maintainer, write]` this command declares. |
There was a problem hiding this comment.
Authorization is now expressed in three places that all have to agree:
- this job's
if:—["OWNER","MEMBER","COLLABORATOR"] - the
permstep below —admin|maintain|maintainer|write pre_activation—roles: [admin, maintainer, write], the only one actually derived from the frontmatter
Change roles: in the frontmatter and 1 and 2 silently keep enforcing the old policy. 2 and 3 are now near-verbatim reimplementations of each other. Since roles: already lists exactly admin, maintainer, write, could you add an explicit "keep in sync with roles: above" note on both hand-written gates?
The root cause is upstream — gh-aw's needs: on a command workflow forces custom jobs ahead of its own authorization gate, and there's no way to invert it (fetch-binlog: needs: pre_activation would cycle). Probably worth an issue on github/gh-aw; this is a footgun any repo doing expensive pre-work in a command workflow will hit.
There was a problem hiding this comment.
Agreed. #17240 adds KEEP IN SYNC with roles: notes to both hand-written gates, spelling out that editing roles: does not update them because only pre_activation is generated from the frontmatter.
And agreed the real footgun is upstream: gh-aw schedules custom needs: jobs ahead of pre_activation, so the only way to gate on cost is to restate the policy by hand. Worth an issue on gh-aw - something like an opt-in pre_activation ordering, or exposing the resolved role as a job output the workflow can consume.
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| COMMENTER: ${{ github.event.comment.user.login }} | ||
| run: | |
There was a problem hiding this comment.
Two small nits on this step, both consistency rather than correctness:
COMMENTER isn't validated before being interpolated into an API path, while the same file rigorously validates PR_NUMBER and BUILD_ID as numeric for exactly that reason. Logins are [A-Za-z0-9-] so there's no live issue, and bot logins like github-actions[bot] fail closed with a 404 — but a grep -qE '^[A-Za-z0-9-]+$' guard would match the defensive style of the rest of the file. (Credit where due: using env: rather than inline ${{ }} correctly avoids the script-injection problem.)
Neither custom step declares shell: bash, while the compiler-generated step directly above them does. Works fine on ubuntu-latest (default is bash -e {0}, and the fetch step's mapfile/PIPESTATUS are happy), but it leaves two bash-only scripts with an implicit dependency on the runner image. Pre-existing and cheap to fix while you're in here.
There was a problem hiding this comment.
Both fixed in #17240.
COMMENTER now gets the same shape check PR_NUMBER and BUILD_ID already had, before it reaches the API path or the log:
if ! printf '%s' "${COMMENTER}" | grep -qE '^[A-Za-z0-9-]+$'; then
echo "::warning::Commenter login is missing or malformed; skipping the binlog download."
echo "authorized=false" >> "$GITHUB_OUTPUT"
exit 0
fiVerified live: github-actions[bot] and an empty value are both rejected before the call, as is foo/../../bar.
shell: bash added to every hand-written run: step in both workflows.
…rency groups Carries over review feedback from dotnet/arcade#17228, where the same pre-gate shipped first. The gate matched the union of `role_name` and `permission` over `admin|maintain|maintainer|write`. The REST docs for `GET /repos/{owner}/{repo}/collaborators/{username}/permission` say `permission` returns the legacy base roles `admin|write|read|none`, "where the maintain role is mapped to write and the triage role is mapped to read", while `role_name` gives "the name of the assigned role, including custom roles". So `.permission in {admin, write}` already means "has push access or better", which is exactly what `roles: [admin, maintainer, write]` describes - maintainers included - and matching `role_name` only risked letting a custom organization role merely *named* like a privileged one clear the gate with no push access. The gate now reads `.permission` alone. Also: extract the field with `jq` from the captured response instead of `gh api --jq`. On a non-2xx response `gh` prints the error document to stdout and `--jq` does not filter it, so the raw JSON would land in `perm` and be echoed into the log. `shell: bash` added to every hand-written `run:` step so the shell is explicit rather than inherited from the runner default. Separately, both workflows resolved their concurrency group to `build-failure-analysis-<pr>`. Groups are repository-global and `cancel-in-progress` is true, so an automatic analysis and an on-demand `/analyze-build-failure` for the same PR cancelled each other; this was observed live in a fork. The command workflow now uses `build-failure-analysis-cmd-<pr>`. Co-authored-by: Copilot <[email protected]> Copilot-Session: e5db9021-5257-4cf5-83ba-486a3e398391
Problem
The
/analyze-build-failureslash command has never run a single time since it was added.For comparison, the same workflow in microsoft/testfx has 12 runs.
Root cause
build-failure-analysis-command.mddeclares:strategy: centralizedtells gh-aw that a separate central dispatcherworkflow owns the
issue_commenttrigger and fans out to command workflows viaworkflow_dispatch. That pattern comes from microsoft/testfx, which has anagentic_commands.ymldispatcher.Arcade has no dispatcher. The only
workflow_callworkflows here arebackport-base.yml,inter-branch-merge-base.ymlandscheduled-action-cleanup-base.yml— none of them gh-aw related.So the compiled lock file listened on
workflow_dispatchonly:…and nothing ever dispatched it. Commenting
/analyze-build-failureon a PR is a no-op.The automatic
build-failure-analysisworkflow (check_runtrigger) is unaffected and runs normally.Fix
Drop
strategy: centralizedso the workflow is self-contained. It now compiles to:and gh-aw generates the
pre_activationrole + command-position check itself.Second, related change: guard
fetch-binlogfetch-binlogis a dependency ofpre_activation, so it runs before the rolecheck. That is fine under
strategy: centralized(the dispatcher alreadyauthorized the caller), but on a decentralized
issue_commenttrigger it woulddownload hundreds of MB of Azure DevOps binlogs on every comment in the repo —
and any public commenter could trigger that repeatedly.
This adds a cheap
if:pre-gate mirroring the same trusted-author predicatepre_activationuses:pre_activationremains the authoritative authorization check; this is purely acost/abuse pre-filter.
Validation
compiler_versionin the lock metadata is unchanged) —0 error(s), 0 warning(s).fetch-binloggate, the compiler-generatedpre_activationgate, and prompt/config hash churn. No unrelated churn.Note: separate, pre-existing problem not addressed here
This PR makes the command fire. It does not fix agent execution, which is
broken in arcade for an unrelated reason:
The auth configuration here is byte-identical to microsoft/testfx, where the agent
succeeds — so this looks like a repo/org-level Copilot entitlement issue rather
than workflow code. Filing separately; flagging here so this PR is not mistaken
for an end-to-end fix.