Conversation
Get returns one artifact with the versions the API returns alongside it, newest first, for gh issue artifact view. Only a single artifact has an edit history, since list responses don't include one, so its --json fields add versions to the artifact fields.
view shows an artifact like gh issue view: its name and issue, who created and last edited it, its body rendered as Markdown or a link's URL, and its edit history. --version shows an earlier version from that history. Piped output has key lines, then the body, and --json adds the versions field. Artifacts have no web page of their own, so the footer links to the issue and --web only opens link artifacts. The shared package gains three checks later commands need too: the artifact number argument, refusing types this version of gh doesn't know, and the strict http(s) URL check for links.
BagToad
added this pull request to stack #14573
October 1, 2026 16:59
gh issue artifact stack 4/10: Add viewgh issue artifact stack 4/11: Add view
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 viewfrom #14524.Description
Issue artifacts are Markdown documents and links attached to an issue. The previous pull request added the
gh issue artifactcommand group andlist. This one addsview, which shows one artifact the waygh issue viewshows an issue:--version 5shows version 5 instead, marked "Viewing".viewuses the pager, likegh issue view. Piped output haskey:lines, then--and the raw body.--jsonhas the same fields aslist, plusversions, the edit history with each version's body.--webopens a link's URL in the browser.list, it refuses pull requests after one lookup and GitHub Enterprise Server before any artifact request. API errors are shown as the API returns them.The client gains
Get, for one artifact and its versions. The shared package gains three checks that later commands need too: the artifact number argument, refusing types gh doesn't know, and a strict check for http(s) URLs.How did you test this change?
I recorded the built
ghin bagtoad/issue-artifacts-demo viewing a document with its edit history,--version, a link, piped output,--json versions,--webon a link and on a document, and an artifact that doesn't exist, each checked withgh api,listorcat -t. It leaves out the pager, issue URL arguments, GitHub Enterprise Server, pull requests and types gh doesn't know.recording.mp4
Open chapters and agent notes
Key points
No artifact URLs yet. [Design]
gh issue artifact view#14524 shows a footer that links to the artifact's own page,--webopening a document's page, artifact URL arguments and aurlfield. The API doesn't return artifact URLs yet, as discussed in RFC:gh issue artifact#14529, soviewkeeps the first design: the footer links to the issue, and--webrefuses a document with "artifact 2 is not a link; --web only opens link artifacts". A later pull request in this stack will add URLs.--versionpicks from the versions the API returned. The API returns them newest first, including the current one.findVersionlooks the number up in that list:--versioncan't be combined with--json, since--json versionshas every version, or with--web.Types gh doesn't know are refused. As discussed in RFC:
gh issue artifact#14529, a new artifact type needs a gh update, since it can need handling gh doesn't have. Until then,viewfails withartifact 7 has type "bad-type", which this version of gh doesn't support; upgrade gh, with--jsontoo.liststill lists them.--webshows the whole URL.gh issue view --webshortens its message withtext.DisplayURL, which drops the port, query and fragment. A link can point anywhere, soviewshows it whole. A link whose stored body isn't an http(s) URL is refused. The shared check accepts only an absolute http or https URL with a host, in printable ASCII with no spaces.The pager is only for the terminal view.
--jsonoutput never pages, likegh discussion viewand unlikegh issue view.listfollows the same rule.The edit history is a table without a header. The bold "Edit history" heading stands in for column headers, so it uses the table printer's
NoHeader, likegh codespace view. "Current" is bold cyan, like "Newest comment" ingh issue view.Null values. A null user shows as
ghostwhen its time exists, and a null time leaves out its part of the line. Piped output prints empty fields, and--jsonkeeps null.Notes for reviewers
Start with the
viewrun function, which shows the order of the checks and the output paths. Then readprintHumanArtifactandprintEditHistoryfor the terminal layout.TestViewRunhas a row for each rule, including a type gh doesn't know, null users and times with and without--version, a pager that fails to start, and a stored link that isn't an http(s) URL.Three messages aren't in #14524, so each follows the closest existing message:
specify only one of `--version` or `--web`, like the--jsonmessage.artifact 3 doesn't link to an http(s) URL; --web only opens http(s) URLs, for a stored link that isn't one.invalid artifact number: "abc", likeinvalid issue format: "abc".Related issues:
gh issue artifact view#14524 is theviewdesign, with a screen for each scenario.gh issue artifact#14529 is the RFC for the command group. Its discussion covers new artifact types and artifact URLs.Authorship and follow-up
Who wrote this:
Who answers review comments: