Skip to content

Defer --attach credential checks to the server - #14805

Merged
BagToad merged 1 commit into
trunkfrom
bagtoad/attach-with-installation-tokens
Oct 23, 2026
Merged

BagToad merged 1 commit into
trunkfrom
bagtoad/attach-with-installation-tokens

Conversation

@BagToad

@BagToad BagToad commented Oct 23, 2026

Copy link
Copy Markdown
Member

Follows #14804

Description

Before it uploads anything, --attach checks the token type and refuses an empty viewerPermission. GraphQL returns no viewerPermission for GitHub App installation tokens, so those tokens still stop here even though their token type is now allowed.

This drops the token check and lets an empty permission through, so the upload endpoint decides. A known READ or TRIAGE permission still fails before anything uploads.

How did you test this change?

Not tested. Exercising the new path needs an installation token from a GitHub App the upload endpoint accepts.

Key points

  • A token the endpoint refuses now fails at upload instead of before any prompt. gh reports the endpoint's 404 as attaching files requires write access to the repository.
  • The unsupported authentication type and could not determine your permission on the repository to attach files errors are gone.
  • The Config options that only fed the token check are removed. ActiveTokenType stays, but is currently unused.

Notes for reviewers

Start with NewUploader. The rest is call-site and test cleanup.

Authorship and follow-up

Who wrote this:

  • A human wrote it.
  • An agent wrote it under close human direction.
  • An agent wrote it independently, and no human has guided the implementation beyond the initial prompt.

Who answers review comments:

  • @BagToad will read and reply directly.
  • An agent will draft replies and @username will read them before they are posted.
  • Nobody has explicitly committed to replying.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 664e416d-0c36-420b-a93c-dbfd8ff83769
@BagToad
BagToad requested a review from a team as a code owner October 23, 2026 19:51
@BagToad
BagToad requested review from niik and a balanced review from Copilot October 23, 2026 19:51

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.

🟢 Approval recommended

The focused behavior change is consistently applied across callers, with regression coverage for empty permissions and retained validation checks, and no unresolved blocking findings.

No open issues 🎉

What changed in this PR

This PR follows #14804 by letting the upload endpoint decide whether credentials can attach files, including GitHub App installation tokens with no GraphQL viewerPermission.

Changes:

  • Removes token-type checks and allows empty permissions while retaining host, repository ID, and known insufficient-permission checks.
  • Updates issue, pull request, and artifact callers, removing configuration dependencies used only for token checks.
  • Adjusts tests and documentation for server-side credential validation.
File Description
skills/​gh/​SKILL.md Documents endpoint-controlled GitHub App support.
pkg/​cmd/​pr/​shared/​commentable.go Removes token lookup from shared comment uploads.
pkg/​cmd/​pr/​shared/​commentable_test.go Covers empty permissions and upload host selection.
pkg/​cmd/​pr/​edit/​edit.go Updates uploader construction and removes unused configuration wiring.
pkg/​cmd/​pr/​edit/​edit_test.go Updates permission and host regression cases.
pkg/​cmd/​pr/​create/​create.go Removes attachment token preflight checks.
pkg/​cmd/​pr/​create/​create_test.go Removes token fixtures and obsolete rejection coverage.
pkg/​cmd/​pr/​comment/​comment.go Removes attachment-only configuration wiring.
pkg/​cmd/​pr/​comment/​comment_test.go Removes the obsolete configuration assertion.
pkg/​cmd/​issue/​edit/​edit.go Updates uploader construction and removes unused configuration wiring.
pkg/​cmd/​issue/​edit/​edit_test.go Removes token fixtures while retaining host coverage.
pkg/​cmd/​issue/​create/​create.go Removes attachment token lookup and configuration wiring.
pkg/​cmd/​issue/​create/​create_test.go Removes attachment token configuration fixtures.
pkg/​cmd/​issue/​comment/​comment.go Removes attachment-only configuration wiring.
pkg/​cmd/​issue/​comment/​comment_test.go Removes the obsolete configuration assertion.
pkg/​cmd/​issue/​artifact/​shared/​shared.go Simplifies the shared uploader helper signature.
pkg/​cmd/​issue/​artifact/​shared/​shared_test.go Updates helper tests for the simplified signature.
pkg/​cmd/​issue/​artifact/​edit/​edit.go Removes configuration plumbing from artifact uploads.
pkg/​cmd/​issue/​artifact/​edit/​edit_test.go Removes obsolete token checks and fixtures.
pkg/​cmd/​issue/​artifact/​create/​create.go Uses the simplified artifact uploader helper.
pkg/​cmd/​issue/​artifact/​create/​create_test.go Removes obsolete token checks and fixtures.
internal/​config/​config.go Adds a comment noting ActiveTokenType is unused.
internal/​attachments/​doc.go Updates preflight guidance and the constructor example.
internal/​attachments/​client.go Removes token allowlisting and permits empty permissions.
internal/​attachments/​client_test.go Updates constructor coverage and retains validation cases.

Review effort: Balanced

@BagToad
BagToad merged commit 4f2cfe9 into trunk Oct 23, 2026
19 checks passed
@BagToad
BagToad deleted the bagtoad/attach-with-installation-tokens branch October 23, 2026 20:08
well-prado added a commit to obi-ai-bot/oby that referenced this pull request Oct 24, 2026
…iewer; no merge without a check (#853, #854)

Review of #1393:
- Approvals come from GET …/pulls/{n}/reviews, every page: gh's
  latestReviews has no commit for an approval (cli/cli#14805). Each
  reviewer's latest review that counts; a comment or a pending review
  never hides a change request.
- An approval counts only from OWNER, MEMBER or COLLABORATOR, never a bot
  or the author, and as the workflow's `review` says: `reviewer` needs
  Oby's reviewer account itself (and needs you while it's signed out),
  `teammate` and `person` anyone but it. An unknown author stops it.
- `checks: none` is gone: nothing merges without a check that passed on
  the head.
- With `merge` or `rebase`, a commit that closes an issue needs you.
- merge() builds home/tmp/merge-<job id> itself.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
well-prado added a commit to obi-ai-bot/oby that referenced this pull request Oct 24, 2026
…iewer; no merge without a check (#853, #854)

Review of #1393:
- Approvals come from GET …/pulls/{n}/reviews, every page: gh's
  latestReviews has no commit for an approval (cli/cli#14805). Each
  reviewer's latest review that counts; a comment or a pending review
  never hides a change request.
- An approval counts only from OWNER, MEMBER or COLLABORATOR, never a bot
  or the author, and as the workflow's `review` says: `reviewer` needs
  Oby's reviewer account itself (and needs you while it's signed out),
  `teammate` and `person` anyone but it. An unknown author stops it.
- `checks: none` is gone: nothing merges without a check that passed on
  the head.
- With `merge` or `rebase`, a commit that closes an issue needs you.
- merge() builds home/tmp/merge-<job id> itself.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
well-prado added a commit to obi-ai-bot/oby that referenced this pull request Oct 24, 2026
…iewer; no merge without a check (#853, #854)

Review of #1393:
- Approvals come from GET …/pulls/{n}/reviews, every page: gh's
  latestReviews has no commit for an approval (cli/cli#14805). Each
  reviewer's latest review that counts; a comment or a pending review
  never hides a change request.
- An approval counts only from OWNER, MEMBER or COLLABORATOR, never a bot
  or the author, and as the workflow's `review` says: `reviewer` needs
  Oby's reviewer account itself (and needs you while it's signed out),
  `teammate` and `person` anyone but it. An unknown author stops it.
- `checks: none` is gone: nothing merges without a check that passed on
  the head.
- With `merge` or `rebase`, a commit that closes an issue needs you.
- merge() builds home/tmp/merge-<job id> itself.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
well-prado added a commit to obi-ai-bot/oby that referenced this pull request Oct 24, 2026
…kflow, typed (#853, #854) (#1393)

* feat(obid): a merge engine that follows each repository's learned workflow, typed (#853, #854)

merge.rs, ported from Engine/Checks.swift: `ready` says whether a job's
pull request may merge by its repository's workflow, or why not (needs
the owner only where Oby can't go on by itself); `merge` reads it again,
checks every rule, writes Oby's own squash words, scans them, merges at
the head it checked and deletes only the job's own oby/ branch;
`wanted_approval` says whose approval it waits on, for the reviewer
account (X1) and a teammate's Oby (X5). Never into main, master or
trunk; the default branch only when the workflow names it.

memory.rs: a typed `workflow` memory ({base, method, rebaseFirst,
review, checks}), saved only by the owner's Remember on its own "Can I
remember that?" (`ask_workflow`), read back with `memory::workflow`.
Free text never drives a merge.

github.rs: the follower's gh pr view also asks for the head's checks,
mergeable, mergeStateStatus, the latest reviews and the author
(`view_merging`, `Merging`). job.rs: mergeError, mergeNeedsYou and
mergedBy come from the job. Nothing calls the merge yet: the follower's
wiring comes next.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(obid): approvals from the REST API, matched to the workflow's reviewer; no merge without a check (#853, #854)

Review of #1393:
- Approvals come from GET …/pulls/{n}/reviews, every page: gh's
  latestReviews has no commit for an approval (cli/cli#14805). Each
  reviewer's latest review that counts; a comment or a pending review
  never hides a change request.
- An approval counts only from OWNER, MEMBER or COLLABORATOR, never a bot
  or the author, and as the workflow's `review` says: `reviewer` needs
  Oby's reviewer account itself (and needs you while it's signed out),
  `teammate` and `person` anyone but it. An unknown author stops it.
- `checks: none` is gone: nothing merges without a check that passed on
  the head.
- With `merge` or `rebase`, a commit that closes an issue needs you.
- merge() builds home/tmp/merge-<job id> itself.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(obid): a reviewer account Oby ever used never passes for a teammate; unknown reviewers merge nothing (#853, #854)

Review of #1393, round 2:
- Every reviewer login Oby uses is kept for good in
  home/github/reviewers.json (0600): `merge::note_reviewer`, for
  keep_reviewer to call on sign-in, and `merge::reviewers`, which notes
  the one signed in now. For `teammate` and `person`, an approval from
  any of them never counts, signed in or not.
- `ready` takes the reviewers or none: when they can't be read, nothing
  merges, whoever approved it.
- The reviews are read again right before the PUT, so a change request
  made during the scan stops it.
- The commits are read on every page.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(obid): a reviewer is recorded when it signs in, and a merge or rebase past 250 commits waits for you (#853, #854)

Review of #1393, round 3:
- github_login's keep_reviewer keeps the reviewer's login for good
  (merge::note_reviewer) before its login is kept, and a login it can't
  record keeps nothing: a reviewer that approves and signs out before any
  merge runs is still known, so its approval never passes for a
  teammate's.
- GitHub lists at most 250 commits of a pull request: past that, a merge
  or rebase method can't be checked for closing keywords, so it needs
  the owner; a squash goes ahead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.

3 participants