Skip to content

Diagnose Copilot assignment credentials only after failures - #67409

Merged
pelikhan merged 5 commits into
mainfrom
pelikhan-fix-assignment-credential-preflight
Oct 10, 2026
Merged

pelikhan merged 5 commits into
mainfrom
pelikhan-fix-assignment-credential-preflight

Conversation

@pelikhan

@pelikhan pelikhan commented Oct 10, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Refs #67374; the issue assessment records dedicated assignment-client HTTP 401 failures while ordinary safe outputs succeed. The selected assignment credential still requires an authorized owner's repair.

Per user direction, diagnostics are failure-only: no GET /user preflight, no extra diagnostic requests on the happy path, and no assignment retries or lower-priority credential fallback. Successful assignment uses its original lookup/assignment flow with one assignment POST.

  • Add selected-credential source and PAT permissions/expiry/access/organization approval/SSO guidance only after authentication or assignment fails; identify known installation tokens without exposing token values.
  • Classify HTTP 401 even when its message is unfamiliar, without probing other aliases.
  • Preserve ordinary credential isolation, staged mode, final required-label gating, assignment error outputs, ignore-if-error, and best-effort failure comments.
  • Add regression coverage proving exact successful request sequences, no diagnostic API calls, and failure-only actionable guidance; update authentication docs.

Validation

  • make fmt-cjs and make lint-cjs passed with repository-pinned stable Prettier.
  • Six focused JS suites: 983 passed, 5 skipped.
  • Final make agent-report-progress passed build, formatting/lint, schema freshness, JavaScript typecheck and impacted tests (133 passed, 2 skipped). It reported three pre-existing warnings in the prior branch's handle_agent_failure.cjs changes, unrelated to this revision. No Go/workflow/compiler changes required recompilation.

No credentials changed and no Actions runs dispatched. This PR fixes diagnostics, not the operational requirement to configure a valid user token and observe successful assignment in a subsequent normally scheduled run. Do not close #67374 solely on merge or a green Actions conclusion.

Refs #67374. Validate the selected user credential before assignment, retain actionable errors without retrying lower-priority tokens, and preserve staging and label gating.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@pelikhan
pelikhan marked this pull request as ready for review October 10, 2026 11:44
Copilot AI balanced review requested due to automatic review settings October 10, 2026 11:44
@github-actions

github-actions Bot commented Oct 10, 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 10, 2026 •

Copy link
Copy Markdown
Contributor

✅ Test Quality Sentinel completed test quality analysis.

Test Quality Sentinel skipped because pre-fetch PR data was unavailable: unable to fetch test file diff

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

✅ Design Decision Gate 🏗️ completed the design decision gate check. See the comment below for the result and any generated ADR draft.

No ADR enforcement needed for PR #67409: the PR does not carry the 'implementation' label and has 0 new lines of code in business logic directories (3 files changed, threshold 100). Source: /tmp/gh-aw/agent/adr-prefetch-summary.json, no custom .design-gate.yml present.

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Code Quality Reviewer completed the code quality review.

No GitHub review was submitted because safeoutputs review-write commands were denied with a non-interactive permission error ('could not request permission from user'). Review findings are reported in the agent response instead.

🔎 Code quality review by PR Code Quality Reviewer

@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

✅ Ponytail Reviewer completed successfully!

Lean already. Ship.

Generated by Ponytail Reviewer for #67409

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

Required-label gating can bypass preflight diagnostics, and per-handler App credentials are misidentified.

2 open findings
What changed in this PR

Adds credential preflight diagnostics for Copilot assignment without changing token precedence or assignment gating.

Changes:

  • Adds cached, timeout-bounded credential validation.
  • Preserves assignment errors while avoiding failed-preflight comments.
  • Adds regression tests and authentication documentation.
File Description
actions/​setup/​js/​assign_to_agent.cjs Implements credential preflight and diagnostics.
actions/​setup/​js/​assign_to_agent.test.cjs Covers credential precedence and failure behavior.
docs/​src/​content/​docs/​reference/​copilot-cloud-agent.mdx Documents preflight scope and remediation.

🧠 Review effort: Balanced


💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment thread actions/setup/js/assign_to_agent.cjs Outdated
Comment thread actions/setup/js/assign_to_agent.cjs Outdated
@github-actions github-actions Bot mentioned this pull request Oct 10, 2026

@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.

Reviewed with Impeccable harden + audit modes (bug-fix/error-state change — credential preflight diagnostics).

Found one blocking correctness issue: the new validateCredential() preflight is ordered after checkRequiredFilter, so handlers configured with required_labels can still surface a raw, unwrapped auth error before the new actionable diagnostics ever run — undermining the PR's core goal for exactly the configuration most likely to need it. See inline comment for details and a suggested fix.

Everything else (lazy/cached preflight, ghs_ rejection without an API call, no token-value leakage, preserved ignore-if-error/staged-mode behavior, docs) looks solid.

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · copilot · sonnet50 · 69.1 AIC · ⌖ 14.2 AIC · ⊞ 8.1K

Comment thread actions/setup/js/assign_to_agent.cjs Outdated

@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 /diagnosing-bugs and /codebase-design on the new credential-preflight path in assign_to_agent.cjs. The change is well-scoped: lazy, cached GET /user check, clear error naming, token redaction in assertions, and solid new test coverage (precedence, 401 vs non-auth status codes, staged/filtered skip, shared-cache-across-messages). Two non-blocking findings below.

📋 Key Themes & Highlights

Key Themes

  • Unsafe property access on caught error (error.name at line 611): if any step in the try block throws a non-Error value, this currently throws a fresh TypeError instead of surfacing the real failure — same defensive pattern used a few lines earlier for error.status should be applied here too.
  • Pre-existing filter duplication now bracketing the new preflight: checkRequiredFilter already ran twice per assignment before this PR; the new validateCredential() call sits between the two checks, tripling relevant API calls per eligible item. Not introduced by this PR, but a short comment explaining the ordering would help future readers avoid conflating the two.

Positive Highlights

  • ✅ Token value never logged or included in thrown errors (verified by rejects.not.toThrow(token) test)
  • ✅ Validation is cached per handler invocation and correctly skipped for staged/filtered assignments
  • ✅ ignore-if-error interaction with 401 vs 403/404/429/500 is explicitly tested — good edge-case coverage per /tdd
  • ✅ Docs update accurately describes the new behavior and its limits (doesn't claim to verify repo write permissions or Copilot availability)

@copilot please address the review comments above.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · sonnet50 · 147.6 AIC · ⌖ 14.6 AIC · ⊞ 10.1K
Comment /matt to run again

Comment thread actions/setup/js/assign_to_agent.cjs Outdated
Comment thread actions/setup/js/assign_to_agent.cjs Outdated
@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot address the following outstanding work in one pass:

  1. Update this branch with the latest main using make merge-main, resolving any conflicts and preserving the intended changes.
  2. Review (actions/setup/js/assign_to_agent.cjs:471): The required-label lookup uses the selected assignment client before validateCredential(). With required_labels configured, an expired credential or known ghs_ installation token therefore makes this API call first, bypassing the actionable preflight wrapper (and, without ignore-if-error, the catch path can attempt a failure comment). This also makes the "reject installation tokens without an API call" behavior untrue for these workflows. Run the early eligibility lookup with a separate read credential, or wrap authentication failures from this lookup with the same preflight error befo... - Diagnose Copilot assignment credentials only after failures #67409 (comment)
  3. Review (actions/setup/js/assign_to_agent.cjs:47): This source label is incorrect when assign-to-agent.github-app is configured. The compiler mints that per-handler App token and serializes it into the same config["github-token"] field (pkg/workflow/safe_outputs_handler_registry_assignments.go:27), so the new rejection reports assign-to-agent.github-token even though no such token was configured. Pass credential-source metadata alongside the resolved token (or use a source-neutral label) so the diagnostic names the actual unsuitable setting. - Diagnose Copilot assignment credentials only after failures #67409 (comment)
  4. Review (actions/setup/js/assign_to_agent.cjs:471): Correctness: credential preflight is skipped when required_labels is configured and the credential is already bad - Diagnose Copilot assignment credentials only after failures #67409 (comment)
  5. Review (actions/setup/js/assign_to_agent.cjs:611): [/diagnosing-bugs] error.name is read without first confirming error is an object, so a non-Error throw anywhere in the try block (e.g. a rejected promise with a plain string/object) would throw a TypeError inside the catch, replacing the original diagnostic with an unrelated crash. - Diagnose Copilot assignment credentials only after failures #67409 (comment)
  6. Review (actions/setup/js/assign_to_agent.cjs:471): [/codebase-design] This try block already called checkRequiredFilter once (two lines above) before the new await validateCredential(), and it's called a second time at the "final" check further down — both predating this PR but now bracketing the new preflight, so every eligible assignment now issues up to 3 extra API round-trips (issues.get ×2 + GET /user) beyond what's strictly needed when the filter result can't change between the two calls in this synchronous span. Not introduced by this PR, but since the new preflight sits directly between the two filter checks, it's worth a... - Diagnose Copilot assignment credentials only after failures #67409 (comment)
  7. Fix failing check lint-js (FAILURE): https://github.com/github/gh-aw/actions/runs/38049468910/job/114205582885.
  8. Fix failing check lint-js (FAILURE): https://github.com/github/gh-aw/actions/runs/38049320850/job/114205178839.

Push the necessary fixes, reply to each listed review thread and resolve it when addressed. Ignore feedback already answered or resolved. Use the pr-finisher skill and stop when only human review or CI remains; do not trigger CI.

Sous-chef head: 3b61c35
Sous-chef work: 397ffad6161c85fd342458941059d88278ade48efa8d81ba35edd9714363c2a7 5a1e830de32a4d4de1b1b1a0c712a1fda661e9a001b55711ae2579b0dc8d1b55 a5acb4c439c8a32a635fde0940099df4e3f5b4ba33047a68ce06d416ac246d6d bbcbbd0ca3f44836842efeccbe6ee4e009cf3d5f19a08d57a88ad2789afa0a2e e914e98d19db3e08b89b888168769da5a972e73b868d7e62f4500b1d7042a85b f554727c0e0b67ffd31d4a76bd3d3e50fb7c44965d6d5d8c9c28ef785d065089
Sous-chef state: daa0e6ff21cd4d22b01623b1fd33fad1c44202bc1ab6d4427ad54cd40dfc556b

Generated by 👨‍🍳 PR Sous Chef · pi · haiku45 · 5.83 AIC · ⌖ 6.07 AIC · ⊞ 1K · ◷
Comment /souschef to run again

Copilot AI and others added 2 commits October 10, 2026 12:40
…nt-credential-preflight

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Remove credential preflight calls from the successful assignment path. Enrich failed assignment diagnostics without additional probes or assignment retries, and retain HTTP 401 classification and existing label gating.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@pelikhan pelikhan changed the title Preflight Copilot assignment credentials with actionable diagnostics Diagnose Copilot assignment credentials only after failures Oct 10, 2026
Move failure-only credential guidance into actions/setup/md and render it with the existing message-template helpers.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@pelikhan
pelikhan merged commit e7d74ed into main Oct 10, 2026
48 of 50 checks passed
@pelikhan
pelikhan deleted the pelikhan-fix-assignment-credential-preflight branch October 10, 2026 13:22
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.

[AW Top 10] 03 Fix agent assignment Bad credentials failures

4 participants