Skip to content

feat(cli): diagnose assign-to-agent credentials in doctor - #72942

Merged
pelikhan merged 5 commits into
mainfrom
pelikhan/super-umbrella
Oct 29, 2026
Merged

pelikhan merged 5 commits into
mainfrom
pelikhan/super-umbrella

Conversation

@pelikhan

@pelikhan pelikhan commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

Why

Workflows using safe-outputs.assign-to-agent can appear configured while falling back to credentials that cannot assign Copilot. Successful workflow conclusions can also mask authentication failures when ignore-if-error is enabled. gh aw doctor should diagnose both credential configuration and recent assignment execution, with actionable setup links.

Changes

  • Inspect standalone local workflows, frontmatter imports, and Markdown includes for assign-to-agent, respecting consumer overrides and excluding import-safe shared fragments.
  • Check repository, inherited organization, and effective environment Actions secret metadata, respecting explicit assignment tokens and every ordered fallback. Skip organization-secret lookup for personal-account repositories and report dynamic or inaccessible environments as unknown.
  • Report missing or unknown credentials with a prefilled PAT creation URL, repository-secret setup URL, and required permissions. Flag unsupported GitHub App installation tokens and GITHUB_TOKEN.
  • Sample up to five completed runs created in the past seven days per assignment workflow, inspecting the latest attempt's assignment handler logs. Bound inspection to 40 API requests and 90 seconds.
  • Distinguish confirmed assignments, already-assigned targets, credential failures, other assignment failures, skipped jobs, and inconclusive or inaccessible evidence. Do not equate successful run conclusions or zero exported errors with successful assignment.
  • Return a nonzero exit status for detected assignment failures even when a secret exists, preserving run links and credential remediation. Expose bounded historical evidence through --json without raw logs.
  • Document the behavior and preserve authentication-only diagnostics outside a checkout. Secret presence and historical execution do not establish current token validity, permissions, expiry, or Copilot availability.

Validation

  • Focused doctor and repository setup tests passed, including credential precedence, imports, enterprise hosts, suppressed failures, actual success markers, duplicate helper/handler messages, unrelated log text, exact run attempts, unavailable metadata/logs, request limits, JSON, and exit-status behavior.
  • Build, formatting, standard and custom Go linters, schema freshness, and impacted unit tests passed.
  • Workflow drift check passed: all 349 workflows compiled with no lock-file changes.
  • Ran the updated doctor on github/gh-aw: it detected credential failures in three sampled issue-monster runs, including https://github.com/github/gh-aw/actions/runs/40859170777, which concluded successfully despite Bad credentials (HTTP 401) and suppressed assignment errors.

ADR: ADR-72942: Assignment credential diagnostics

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]>
@pelikhan
pelikhan marked this pull request as ready for review October 29, 2026 11:07
Copilot AI adaptive review requested due to automatic review settings October 29, 2026 11:07
@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer

@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

✅ Ponytail Reviewer completed successfully!

Ponytail Reviewer

Outcome: reported_no_action

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.

Generated from Ponytail Reviewer · gpt56 · ~15 AIC · ⌖ ~7 AIC · ⊞ 14.8K · ◷

Generated by Ponytail Reviewer for #72942

@github-actions

Copy link
Copy Markdown
Contributor

🔎 PR Code Quality Reviewer is reviewing code quality for this pull request...

@github-actions

This comment has been minimized.

@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

✅ Test Quality Sentinel completed test quality analysis.

Test Quality Sentinel

Outcome: reported_no_action

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.

Generated from Test Quality Sentinel · haiku45 · ~5 AIC · ⌖ ~8 AIC · ◇ ~2 AIC · ⊞ 8.9K · ◷

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

Copy link
Copy Markdown
Contributor

🏗️ Design Decision Gate — ADR Required

This PR makes significant changes to core business logic (765 new lines under pkg/) but does not have a linked Architecture Decision Record (ADR).

📄 Draft ADR committed: docs/adr/72942-diagnose-assign-to-agent-credentials-via-secret-metadata.md — review and complete it before merging.

🔒 This PR cannot merge until an ADR is linked in the PR body.

The draft records the decision to have gh aw doctor check assign-to-agent credentials using repository and organization secret metadata. The check parses the token expression to follow fallback precedence. It treats GITHUB_TOKEN and github-app as missing, reports dynamic expressions or failed lookups as unknown, and exits nonzero for anything not configured. The draft also compares this against token-validity probing, runtime-only detection, and compile-time validation.

📋 What to do next
  1. Review the draft ADR committed to your branch. It was generated from the PR diff.

  2. Complete the missing sections. Add context the AI couldn't infer, refine the decision rationale, and confirm the alternatives (deciders are marked [TODO: verify]).

  3. Commit the finalized ADR to docs/adr/ on your branch.

  4. Reference the ADR in this PR body by adding a line such as:

    ADR: ADR-72942: Diagnose assign-to-agent Credentials in gh aw doctor via Secret Metadata (link unavailable: invalid HTTPS URL)

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

"AI made me procrastinate on key design decisions. Because refactoring was cheap, I could always say 'I'll deal with this later.' Deferring decisions corroded my ability to think clearly."

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 Reference

An ADR must contain these four sections to be considered complete:

  • Context — What is the problem? What forces are at play?
  • Decision — What did you decide? Why?
  • Alternatives Considered — What else could have been done?
  • Consequences — What are the trade-offs (positive and negative)?

All ADRs are stored in docs/adr/ as Markdown files numbered by PR number.

🏗️ ADR gate enforced by Design Decision Gate 🏗️ · pi · opus55 · ~31 AIC · ⌖ ~42 AIC · ⊞ 1.9K · ◷
Comment /review to run again

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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
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)

Comment thread pkg/cli/doctor_assign_to_agent.go Resolved
Comment thread pkg/cli/doctor_assign_to_agent.go Resolved
Comment thread pkg/cli/doctor_assign_to_agent.go Resolved
Comment thread pkg/cli/doctor_assign_to_agent.go Resolved
Comment thread pkg/cli/doctor_assign_to_agent.go Resolved

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

  • listDoctorAssignmentSecrets fails hard on personal/user-owned repos (pkg/cli/doctor_assign_to_agent.go:153-180): the organization-secrets Actions 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 to unknown. Since many gh-aw users run doctor against personal-account checkouts, this likely makes the new diagnostic non-actionable for a large fraction of users. No existing test exercises the diagnoseDoctorAssignments-level outcome for this scenario (only listDoctorAssignmentSecrets in isolation), so the regression wasn't caught.

Verified correct (no action needed)

  • ✅ config.GitHubApp != nil → missing check in diagnoseDoctorAssignments matches real compiled behavior — confirmed via resolveHandlerGitHubToken in safe_outputs_handler_registry_assignments.go, which always prefers the GitHub App step-token expression over an explicit GitHubToken fallback whenever an App is configured.
  • ✅ Expression-parsing logic (doctorAssignmentSecretNames/doctorAssignmentSecretReferences) correctly limits itself to static secrets.NAME / || chains and reports unknown for 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, so unknown results 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

Comment thread pkg/cli/doctor_assign_to_agent.go Resolved
Comment thread pkg/cli/doctor_assign_to_agent_test.go Resolved
Comment thread docs/src/content/docs/setup/cli.md Resolved
@pelikhan

Copy link
Copy Markdown
Collaborator Author

No standalone code change is needed for this review completion notice. The substantive skills-review findings are addressed in their inline threads.

@pelikhan

Copy link
Copy Markdown
Collaborator Author

The Ponytail Reviewer result reports no actionable finding, so no code change is warranted for this notice.

@pelikhan

Copy link
Copy Markdown
Collaborator Author

This code-quality review notification contains no actionable finding, so no code change is needed for the notification itself.

@pelikhan

Copy link
Copy Markdown
Collaborator Author

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.

@pelikhan

Copy link
Copy Markdown
Collaborator Author

The Test Quality Sentinel result reports no actionable finding, so no standalone code change is warranted for this notice.

@pelikhan

Copy link
Copy Markdown
Collaborator Author

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.

@pelikhan
pelikhan merged commit a63196f into main Oct 29, 2026
109 of 110 checks passed
@pelikhan
pelikhan deleted the pelikhan/super-umbrella branch October 29, 2026 12:03
@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v1.2.0

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.

2 participants