Conversation
Delete removes one artifact from an issue, for gh issue artifact delete. The API can't restore a deleted artifact.
delete asks before deleting, since a deleted artifact can't be restored. It looks up every number first, so the prompt names each artifact, and without --yes a number that can't be found stops the command before anything is deleted. --yes skips the prompt and is required when gh can't prompt, like gh label delete. Commands that act on several artifacts report one line per artifact. The shared package gains those result lines, so each such command prints the same terminal lines and the same five-column piped lines.
BagToad
added this pull request to stack #14573
October 1, 2026 16:59
gh issue artifact stack 5/10: Add deletegh issue artifact stack 5/11: Add delete
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of the pull request stack tracked in #14563.
This adds
gh issue artifact deletefrom #14527.Description
Issue artifacts are Markdown documents and links attached to an issue. The previous pull requests added the
gh issue artifactcommand group,listandview. This one addsdelete, which deletes artifacts by number. A deleted artifact can't be restored, so in a terminal gh asks first:One prompt names every artifact, and its default is No. Declining deletes nothing and exits 2, like other gh prompts.
--yesskips the prompt. Without a terminal,--yesis required, likegh label delete.Without
--yes, a number that can't be found stops the command before the prompt, withX Failed to delete artifact 9: Not FoundandNo artifacts were deleted.With
--yes, every number is attempted. Each artifact gets its own line, failures show the API's message, and any failure exits 1.Piped, each artifact gets one line with five tab-separated columns: status, number, name, source and reason.
deletehas no source, so that column is empty:Like
listandview, it refuses pull requests after one lookup and GitHub Enterprise Server before any artifact request. Types gh doesn't know are deleted as usual.The client gains
Delete. The shared package gains the result lines, which the later commands in the stack reuse.How did you test this change?
I recorded the built
ghin bagtoad/issue-artifacts-demo, each case on a fresh issue and checked withgh issue artifact list: confirming the prompt, declining it, three artifacts with--yes, a missing number with--yes, piped output,--yesrequired without a terminal, and a missing number stopping the command before the prompt. It leaves out issue URL arguments, pull requests, GitHub Enterprise Server and types gh doesn't know.recording.mp4
Open chapters and agent notes
Key points
No artifact URLs yet. [Design]
gh issue artifact delete#14527 also names artifacts by their URLs. The API doesn't return artifact URLs yet, as discussed in RFC:gh issue artifact#14529, sodeletetakes an issue and numbers, and its help leaves URLs out. A later pull request in this stack will add them.Every number is looked up first. The prompt and the result lines name each artifact, so
deleteRungets every artifact before deleting any:With
--yes, a number whose lookup fails gets a failed line, and gh sends no delete request for it. The other numbers are still deleted.The result lines are shared.
download,createandeditreport each artifact the same way, soPrintSuccessandPrintFailurelive in the shared package. In a terminal, successes go to stdout and failures to stderr, likegh issue editwith several issues. Piped, every line goes to stdout, likegh pr checksrows. The line already names the artifact, so its reason is only the API's message:Not Found, notHTTP 404: Not Found (<url>).Streams around the prompt. The warning goes to stdout, before the prompt, like
gh issue deleteandgh issue comment --delete-last.No artifacts were deleted.goes to stderr, after the failed lines.A repeated number isn't merged. Each argument gets one line, so
delete 142 2 2 --yesdeletes artifact 2, then reportsFailed to delete artifact 2: Not Found.Notes for reviewers
Start with the
deleterun function, which shows the order of the checks, the lookups, the prompt and the deletes. Then read the shared result lines.TestDeleteRunhas a row for each rule, including a failed lookup before the prompt, a failed delete after a lookup, a type gh doesn't know and a repeated number.One detail isn't in #14527:
gh issue artifact delete#14527 shows prompts for one and two artifacts. With three or more,deleteseparates them with commas, including one before "and", like gh's other lists:Delete artifacts 2 (OAuth callback plan), 3 (Staging OAuth runbook), and 5 (Barista feedback notes) from monalisa/monas-cafe#142?Related issues:
gh issue artifact delete#14527 is thedeletedesign, with a screen for each scenario.gh issue artifact#14529 is the RFC for the command group. Its discussion covers artifact URLs.Authorship and follow-up
Who wrote this:
Who answers review comments: