cli icon indicating copy to clipboard operation
cli copied to clipboard

`--attach` requires write access, so outside reporters cannot attach screenshots

Open claell opened this issue 3 months ago • 9 comments

Describe the feature or problem you’d like to solve

First, thank you for shipping this. #13256 and the stack at #14186 closed a request that had been open in one form or another since #1895 in 2020, and the design is better than the workarounds it replaces — being able to write ordinary markdown against local paths and have those references rewritten on upload means a report drafted offline stays readable before it is ever posted. I am very glad to see it land.

One gap, from the read-only side of the fence.

--attach accepts a credential only when its permission on the target repository is ADMIN, MAINTAIN or WRITE:

// uploadPermissions lists the repository permissions that can attach a file.
// The list matches api.Repository.ViewerCanPush, and it is measured against the
// upload endpoint: READ and TRIAGE get a 404.
var uploadPermissions = []string{"ADMIN", "MAINTAIN", "WRITE"}

— internal/attachments/client.go

That excludes the group that most often needs to attach a screenshot to an issue: the outside reporter, who has READ. I use gh to follow up on my own open issues, and viewerPermission is READ on every repository I track — this one included — so --attach is unavailable for all of them:

repository viewerPermission
cli/cli READ
openai/codex READ
microsoft/vscode READ
anthropics/claude-code READ
tauri-apps/tray-icon READ

Meanwhile the same account can drag a screenshot into a comment on any of those repositories through the web UI and it renders. That asymmetry is visible in this tracker: in #12960, drogers0 — author_association: NONE on this repository — posted a github.com/user-attachments/assets/… image scoped to cli/cli, using an extension that replicates the web upload flow with a browser session cookie. So the platform does permit a read-only user to create one of these assets. It is the token-authenticated path that refuses.

Proposed solution

  1. If the 404 for READ/TRIAGE is a property of POST /user-attachments/assets rather than a CLI decision, say so — here, and ideally on github/roadmap#1324, which describes the feature with no mention of a permission requirement. That tells people where the ask actually belongs, which is the same courtesy #12960 got when the blocker was the missing API.
  2. If the endpoint can serve a user who is permitted to comment on the repository, please allow that. Permission to comment, rather than permission to push, is what gates the equivalent web-UI upload.
  3. Either way, document the requirement in the --attach help. The long help for gh issue create covers the 50-file limit, the alt-text syntax and the partial-failure behaviour, but neither the permission requirement nor the GitHub Enterprise Server exclusion, so a read-only user meets both only as an error.

Point 3 stands on its own and is worth doing even if 1 and 2 are declined.

Additional context

I have not run the preview build — the artifacts linked from #13256 expired on 25 August, and this has not shipped in a release yet (latest is 2.98.0 from 2026-08-20; the stack merged 2026-08-25). The above is read from the merged code on trunk, so please correct me if the released behaviour differs.

claell avatar Aug 31 '26 15:08 claell

Thanks for the detailed writeup. I'm suggesting the enhancement label: this describes a real gap in the recently-shipped --attach feature (#13256/#14186) where the upload endpoint's permission check (ADMIN/MAINTAIN/WRITE) excludes read-only outside reporters from attaching files, even though the same accounts can upload via the web UI. I checked for duplicates and didn't find an exact match — #14194 and #12960 request the underlying attach capability itself, which has since shipped, so this is a distinct follow-up about the permission requirement and its documentation. A maintainer should confirm whether the READ/TRIAGE restriction is enforced by the platform API itself or is a CLI-side choice, since that determines whether points 1–2 are actionable here versus upstream, though point 3 (documenting the requirement in --attach help) seems actionable regardless.

Generated by Issue Triage (skills-driven) for #14302 · copilot · auto · 21.4 AIC · ⌖ 2.84 AIC · ⊞ 9.7K · ◷

cli-triage[bot] avatar Aug 31 '26 15:08 cli-triage[bot]

Thank you for your issue! We have categorized it as an enhancement (feature or improvement) request, and it has been added to our backlog. In doing so, we are not committing to implementing this feature at this time, but, we will consider it for future releases based on community feedback and our own product roadmap.

Unless you see the https://github.com/cli/cli/labels/help%20wanted label, we are not currently looking for external contributions for this feature.

If you come across this issue and would like to see it implemented, please add a thumbs up! This will help us prioritize the feature. Please only comment if you have additional information or viewpoints to contribute.

github-actions[bot] avatar Sep 01 '26 15:09 github-actions[bot]

Thank you for your issue! We have categorized it as an enhancement (feature or improvement) request, and it has been added to our backlog. In doing so, we are not committing to implementing this feature at this time, but, we will consider it for future releases based on community feedback and our own product roadmap.

Unless you see the https://github.com/cli/cli/labels/help%20wanted label, we are not currently looking for external contributions for this feature.

If you come across this issue and would like to see it implemented, please add a thumbs up! This will help us prioritize the feature. Please only comment if you have additional information or viewpoints to contribute.

github-actions[bot] avatar Sep 01 '26 15:09 github-actions[bot]

gh-image banner

While waiting on something first party, gh-image attaches from read-only access today, so outside reporters can post screenshots.

It uses the same upload path as drag and drop in the web UI, which only needs pull permission.

drogers0 avatar Sep 08 '26 22:09 drogers0

Yep when using --attach I encounter: attaching files requires write access to the repository for repos I don't own. Via the UI I can add a screenshot however. I'm using my personal github token.

tekumara avatar Sep 13 '26 12:09 tekumara

Another case this blocks: pull requests from forks. Opening penso/herdr-gpui#922 from a fork, the repo's PR template asks for before/after screenshots, but gh pr create --attach stopped with attaching files requires write access to the repository before creating anything. The same happened with gh issue create --attach for the linked issue (penso/herdr-gpui#921). Both were opened without images, and the screenshots were dragged in through the web UI afterwards.

On point 3: in gh 2.103.0, --help for gh pr create and gh issue create still doesn't mention the permission requirement. It's documented only in the gh agent skill (skills/gh/SKILL.md, "Attaching images and videos").

adehad avatar Oct 30 '26 16:10 adehad

Same case here, from an outside reviewer (gh 2.103.0, Windows).

I reviewed a contributor's PR on a repo where I only have read access, generated the evidence locally (test runs, generated-project builds) and tried to post the screenshots:

$ gh pr comment 1030 -R bancolombia/scaffold-clean-architecture --body-file shots.md --attach ./01-unit-tests.png --attach ./02-generated-builds.png --attach ./03-runtime.png
attaching files requires write access to the repository

On github.com the same account can drag those images into the comment box of that PR without any extra permission. Since gh pr comment already succeeds without write access, it would help if --attach used the same rule as the web comment box: if you can comment, you can attach.

Ludocius avatar Nov 10 '26 19:11 Ludocius

Before-and-after screenshots are a common part of reviewing a UI change. If I can open a PR from a fork and drag those screenshots into its description on github.com, I’d like to be able to do the same with gh pr create --attach. Adding images to my own PR shouldn’t require permission to push code to the upstream repository.

ousugo avatar Nov 25 '26 22:11 ousugo

While an official solution is not available, here's mine:

  • https://github.com/felipecrs/agent-attachments

felipecrs avatar Nov 26 '26 19:11 felipecrs