Repository navigation
feat(cli): diagnose assign-to-agent credentials in doctor - #72942
Conversation
Detect assignment safe outputs and imported configuration, check repository and inherited Actions secret metadata, and report actionable PAT setup links without exposing or claiming to validate stored credentials. Co-authored-by: Copilot App <[email protected]>
|
🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅
|
|
✅ Ponytail Reviewer completed successfully! Ponytail ReviewerOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
🔎 PR Code Quality Reviewer is reviewing code quality for this pull request... |
This comment has been minimized.
This comment has been minimized.
|
✅ Test Quality Sentinel completed test quality analysis. Test Quality SentinelOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
🏗️ Design Decision Gate — ADR RequiredThis PR makes significant changes to core business logic (765 new lines under 📄 Draft ADR committed:
The draft records the decision to have 📋 What to do next
Once an ADR is linked in the PR body, this gate will re-run and verify that the implementation matches the decision. ❓ Why ADRs Matter
ADRs create a searchable, permanent record of why the codebase looks the way it does. Future contributors (and your future self) will thank you. 📋 Michael Nygard ADR Format ReferenceAn ADR must contain these four sections to be considered complete:
All ADRs are stored in
|
There was a problem hiding this comment.
🟡 Changes recommended
Assignment diagnostics can incorrectly fail valid workflows, skip credential checks for Markdown-included assignments, and abort on valid authenticated remote URLs.
5 open issues
Parse authenticated HTTPS remotes without splitting userinfo · New Ignore import-safe shared workflow blocks in credential checks · New Include Markdown @include safe outputs in credential checks · New Check environment-scoped secrets for safe-output credentials · New Visit all fallback operands in credential expressions · New
What changed in this PR
Extends gh aw doctor with credential diagnostics for safe-outputs.assign-to-agent, helping users identify configuration problems before running workflows.
Changes:
- Discovers assignment configuration and checks repository and inherited organization secret metadata.
- Adds credential status, setup links, JSON results, and nonzero exit status when attention is needed.
- Adds tests and documents diagnostic behavior and verification limits.
| File | Description |
|---|---|
pkg/cli/setup_repository.go |
Integrates assignment checks into authentication and repository diagnostics. |
pkg/cli/doctor_command.go |
Enables assignment checks and updates command help. |
pkg/cli/doctor_command_test.go |
Verifies assignment checks are enabled by the command. |
pkg/cli/doctor_assign_to_agent.go |
Implements discovery, secret checks, credential analysis, and setup guidance. |
pkg/cli/doctor_assign_to_agent_test.go |
Covers discovery, credentials, API responses, hosts, and output behavior. |
docs/src/content/docs/setup/cli.md |
Documents assignment diagnostics, limitations, and exit behavior. |
Review effort: Balanced (auto)
Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
There was a problem hiding this comment.
Skills-Based Review 🧠
Applied /tdd and /grill-with-docs (per pr-triage classification of new_feature). The overall design is sound — the new doctor diagnostic correctly reflects real token-resolution semantics (verified AssignToAgent.GitHubApp != nil genuinely bypasses AssignToAgent.GitHubToken at compile time via resolveHandlerGitHubToken, so that part of the logic is not a bug as initially suspected). However, there is one concrete, high-impact bug that should block merge.
📋 Key Findings
Blocking issue
listDoctorAssignmentSecretsfails hard on personal/user-owned repos (pkg/cli/doctor_assign_to_agent.go:153-180): theorganization-secretsActions API endpoint returns 403/404 for personal repositories (verified live against a user-owned repo). The function currently treats any non-200 on either endpoint as a fatal error, discarding repository secrets already fetched successfully and degrading every workflow check tounknown. Since many gh-aw users rundoctoragainst personal-account checkouts, this likely makes the new diagnostic non-actionable for a large fraction of users. No existing test exercises thediagnoseDoctorAssignments-level outcome for this scenario (onlylistDoctorAssignmentSecretsin isolation), so the regression wasn't caught.
Verified correct (no action needed)
- ✅
config.GitHubApp != nil → missingcheck indiagnoseDoctorAssignmentsmatches real compiled behavior — confirmed viaresolveHandlerGitHubTokeninsafe_outputs_handler_registry_assignments.go, which always prefers the GitHub App step-token expression over an explicitGitHubTokenfallback whenever an App is configured. - ✅ Expression-parsing logic (
doctorAssignmentSecretNames/doctorAssignmentSecretReferences) correctly limits itself to staticsecrets.NAME/||chains and reportsunknownfor anything dynamic — well tested across 8+ edge cases. - ✅ Good test coverage for credential precedence, JSON/exit-status behavior, and GHE host handling.
Minor / documentation
- The CLI docs (
docs/src/content/docs/setup/cli.md) should clarify the owner-type-dependent behavior once the organization-secrets handling is fixed, sounknownresults aren't surprising for personal-repo users.
Requesting changes primarily for the organization-secrets failure handling on personal repos — everything else is solid. Note: given the scope of this review, token-resolution investigation was bounded to the areas directly touched by this PR; the broader safe-outputs handler registry was spot-checked but not exhaustively audited.
🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · sonnet50 · ~247 AIC · ⌖ ~19 AIC · ⊞ 10.2K
Comment /matt to run again
Co-authored-by: Copilot App <[email protected]>
|
No standalone code change is needed for this review completion notice. The substantive skills-review findings are addressed in their inline threads. |
|
The Ponytail Reviewer result reports no actionable finding, so no code change is warranted for this notice. |
|
This code-quality review notification contains no actionable finding, so no code change is needed for the notification itself. |
|
Accepted the ADR follow-up: completed the generated record with the configuration and recent-run decisions, alternatives, and limits, and linked it in the PR body. Its status is Proposed pending PR acceptance, not a claim of maintainer approval. |
|
The Test Quality Sentinel result reports no actionable finding, so no standalone code change is warranted for this notice. |
|
Accepted the ADR requirement: reviewed and completed ADR-72942, removed its TODOs, documented the implemented metadata and recent-run behavior, and linked the record in the PR body. The record remains Proposed pending PR acceptance rather than claiming reviewer approval. |
|
🎉 This pull request is included in a new release. Release: |

Why
Workflows using
safe-outputs.assign-to-agentcan appear configured while falling back to credentials that cannot assign Copilot. Successful workflow conclusions can also mask authentication failures whenignore-if-erroris enabled.gh aw doctorshould diagnose both credential configuration and recent assignment execution, with actionable setup links.Changes
assign-to-agent, respecting consumer overrides and excluding import-safe shared fragments.GITHUB_TOKEN.--jsonwithout raw logs.Validation
github/gh-aw: it detected credential failures in three sampledissue-monsterruns, including https://github.com/github/gh-aw/actions/runs/40859170777, which concluded successfully despiteBad credentials (HTTP 401)and suppressed assignment errors.ADR: ADR-72942: Assignment credential diagnostics