Skip to content

fix(github): count gh pr and issue commands against the GraphQL rate limit - #28778

Merged
nwparker merged 2 commits into
stablyai:mainfrom
zanmlakar:zanmlakar/gh-graphql-rate-limit
Oct 28, 2026
Merged

nwparker merged 2 commits into
stablyai:mainfrom
zanmlakar:zanmlakar/gh-graphql-rate-limit

Conversation

@zanmlakar

Copy link
Copy Markdown
Contributor

ELI5

GitHub gives each user separate hourly allowances for its two APIs, REST and GraphQL. When an allowance runs out, Orca has a safety switch that stops calling GitHub for a while instead of firing requests that will fail. Most gh pr and gh issue commands use GraphQL, but Orca counted them as REST and didn't recognise GitHub's GraphQL "limit reached" message. So when GraphQL ran out, the switch never flipped and Orca kept trying. Now it flips, and REST calls keep working in the meantime.

What Changed

  • Which limit a command counts against, before: every gh command except gh api and gh search counted against REST.

  • After: these gh subcommands, which Orca runs and which use GraphQL, count against GraphQL:

    • pr checks/close/create/edit/list/merge/ready/reopen/view
    • issue close/edit/list/reopen/view
    • repo view

    Everything else, such as gh run list and gh auth status, stays on REST.

  • Detecting the limit, before: only API rate limit exceeded tripped the breaker.

  • After: GraphQL's API rate limit already exceeded trips it too. Secondary rate limits are still left to the existing retry logic.

  • Project view: issue close and reopen now check and count the GraphQL limit instead of REST.

  • Docs: in docs/site/content/docs/github-errors.mdx, the table now says which commands use which API, the triage row mentions the GraphQL message, and there's a real GraphQL check command next to the REST one.

One subcommand uses both APIs: gh pr edit changes reviewers over REST on GitHub Enterprise. A REST limit hit there trips the GraphQL limit instead. Right after the breaker trips, Orca runs its existing follow-up check (gh api rate_limit, which doesn't count against any limit). That check reads every limit and corrects the block.

Why

Details and gh source links are in #28767.

Alternatives considered:

  • Map whole command groups (pr, issue, repo) to GraphQL: shorter, but not every subcommand is pure GraphQL. I listed only the subcommands Orca runs and checked each one against gh's source. Unlisted ones stay on REST, as before.
  • Pick the limit from the error text (GraphQL: …) when it trips: that covers recording the block, but the breaker also has to decide which limit to check before starting a command. That still needs the command-to-limit mapping.

Linked Issue

Fixes #28767

Visual Proof

N/A. No UI changed. The main process stops starting gh commands while GraphQL is exhausted and reports the existing rate-limit error. The docs edit is a table-and-text change to one page; I didn't render the docs site.

Testing

  • On this branch alone (cut from main at 3879c6d): oxlint, oxfmt --check, and tsc (node project) are clean, and vitest on the branch's changed and neighbouring test files passes (3 files, 37 tests).

  • Changed tests:

    • src/main/git/gh-rate-limit-breaker.test.ts: every listed subcommand counts against GraphQL, while REST endpoints, run list, auth status and a bare pr stay on REST. GraphQL's wording counts as a primary limit. The old assertion that pr list is REST is replaced.
    • src/main/git/runner-gh-rate-limit-breaker.test.ts: a pr view that fails with the GraphQL message blocks only GraphQL. A following issue close is refused without starting gh, and a REST gh api call still runs. The GitHub Enterprise host-scoping tests now check the GraphQL limit.
    • src/main/github/project-view/mutations.test.ts: project-view close and reopen check and count GraphQL.
  • Unit tests: Vitest (the runner behind pnpm test) passed on these files and on every other gh runner test and test under src/main/github.

  • Typecheck and lint: tsc --noEmit -p config/tsconfig.node.json (what pnpm tc:node runs) and oxlint are clean, and oxfmt --check is clean on the changed files and the .mdx.

  • Platforms: tests run on Linux only.

  • Not tested: against a real exhausted GitHub limit. gh is mocked in the tests.

  • SSH and WSL: the breaker keeps its existing per-host scoping, and only the choice of limit changes.

  • Not run locally: the full pnpm lint, pnpm typecheck and pnpm build.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

AI Disclosure

Written with Claude Code (Claude Opus 5.5).

Review

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Ensure no issues in: Security, Cross-platoform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@coderabbitai

coderabbitai Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Walkthrough

The rate-limit breaker now classifies selected issue, pull request, and repository commands as GraphQL requests. It recognizes both REST and GraphQL primary rate-limit error wording. Tests verify that blocking the GraphQL bucket does not block REST calls. Issue-state mutations now check and record GraphQL quota usage. The documentation distinguishes REST and GraphQL limits and includes separate diagnostic probes.

Priority: Normal

Severity of issue fixed: Medium

Merge Risk: Moderate · up to 574b6

GitHub Enterprise reviewer updates can be incorrectly blocked or misreported when the core rate limit is exhausted. Make pr edit classification host-aware before merging.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: counting gh pr and gh issue commands against the GraphQL rate limit.
Description check Passed The description follows the required template and explains the user impact, mechanism, rationale, linked issue, testing, platform coverage, limitations, and checklist status. It clearly discloses that…
Linked Issues check Passed The PR satisfies the coding requirements in [#28767]. classifyGhRateLimitBucket maps the specified pr, issue, and repo view subcommands to graphql and keeps other commands on core or `sear…
Out of Scope Changes check Passed The changes remain within [#28767]. Source changes implement command classification, GraphQL error detection, and project-view quota handling. Tests verify the changed behavior. Documentation updates …
Full details: Description check

Explanation

The description follows the required template and explains the user impact, mechanism, rationale, linked issue, testing, platform coverage, limitations, and checklist status. It clearly discloses that the full lint, typecheck, test, and build commands were not run.

Full details: Linked Issues check

Explanation

The PR satisfies the coding requirements in [#28767]. classifyGhRateLimitBucket maps the specified pr, issue, and repo view subcommands to graphql and keeps other commands on core or search. isGhPrimaryRateLimitStderr recognizes both API rate limit exceeded and API rate limit already exceeded, while excluding secondary limits. Project-view issue close and reopen use the graphql guard and spend bucket. The reported tests cover GraphQL blocking, continued REST calls, host scoping, and project-view quota handling.

Full details: Out of Scope Changes check

Explanation

The changes remain within [#28767]. Source changes implement command classification, GraphQL error detection, and project-view quota handling. Tests verify the changed behavior. Documentation updates describe the API buckets, error messages, and diagnostic commands. No unrelated product change is identified.

Full details: Docstring Coverage

Explanation

Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 3 functions across 5 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

zanmlakar and others added 2 commits October 27, 2026 22:38
…limit

gh serves pr/issue/repo view-style subcommands over GraphQL, but the breaker
filed every non-api command under core and only matched REST's
"API rate limit exceeded" wording, so GraphQL exhaustion never tripped it.
Map those subcommands to the graphql bucket, match GraphQL's
"API rate limit already exceeded", and guard project-view issue close/reopen
against the GraphQL quota.

Fixes stablyai#28767
Keeps the flaky-test-pattern ratchet at its baseline.
@nwparker
nwparker force-pushed the zanmlakar/gh-graphql-rate-limit branch from 9f5de6c to 574b6cb Compare October 28, 2026 05:39
@nwparker

Copy link
Copy Markdown
Contributor

Thanks for this, @zanmlakar. Classifying the GraphQL-backed gh pr/gh issue subcommands into the graphql bucket, plus recognizing the "already exceeded" GraphQL message, fixes a real gap.

We rebased the branch onto current main. There were no conflicts. Our one fixup is a small test cleanup that drops redundant Date.now() arguments in the graphql breaker test. This will merge once CI is green.

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

Actionable comments posted: 1


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f3762a8c-5401-4472-a033-b59f1d9d7287
Commits

Reviewing files that changed from the base of the PR and between 9f5de6c and 574b6cb.

Files selected for processing: 5
  • src/main/git/gh-rate-limit-breaker.test.ts
  • src/main/git/gh-rate-limit-breaker.ts
  • src/main/git/runner-gh-rate-limit-breaker.test.ts
  • src/main/github/project-view/mutations.test.ts
  • src/main/github/project-view/mutations.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.

Comment on lines +81 to +97
// gh serves these over GraphQL; a mixed REST trip (e.g. GHES `pr edit` reviewers) is corrected by the reset probe.
const GH_GRAPHQL_SUBCOMMANDS = new Map<string, ReadonlySet<string>>([
['issue', new Set(['close', 'edit', 'list', 'reopen', 'view'])],
[
'pr',
new Set(['checks', 'close', 'create', 'edit', 'list', 'merge', 'ready', 'reopen', 'view'])
],
['repo', new Set(['view'])]
])

export function classifyGhRateLimitBucket(args: readonly string[]): GhRateLimitBucket {
const command = args[0]
if (command === 'search') {
return 'search'
}
if (command !== 'api') {
return 'core'
return GH_GRAPHQL_SUBCOMMANDS.get(command)?.has(args[1]) ? 'graphql' : 'core'

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.

Minor · Stability & Availability · Quick win

Supported by static analysis

Script executed:

git show 574b6cbf0e42de642d20c618dba6588498bcbbbb:src/main/git/gh-rate-limit-breaker.ts | sed -n '70,140p'
rg -n -C 5 'ghExecFile(WithScope)?Async|add-reviewer|remove-reviewer|issue (close|reopen)|rateLimit' src/main/github src/main/git
rg -n -C 3 'gh.*version|cli.*version|GHES|enterprise|github.com' package.json src config docs | head -240

Repository: stablyai/orca

Length of output: 45664


Script executed:

set -o pipefail
printf '%s\n' '--- changed diff ---'
git diff --no-ext-diff --unified=40 66e2d3982788a763c9202a13a7fdc833dc7334db 574b6cbf0e42de642d20c618dba6588498bcbbbb -- src/main/git/gh-rate-limit-breaker.ts src/main/github src/main/git docs package.json | sed -n '1,1200p'
printf '%s\n' '--- reviewer call sites ---'
rg -n -C 12 --glob '*.ts' -e 'add-reviewer' -e 'remove-reviewer' -e 'pr[[:space:]]+edit' src/main
printf '%s\n' '--- project close/reopen call sites ---'
rg -n -C 16 --glob '*.ts' -e 'project.*(close|reopen)' -e '(close|reopen).*project' -e 'issue.*(close|reopen)' -e '(close|reopen).*issue' src/main/github src/main/git
printf '%s\n' '--- gh command wrappers and version declarations ---'
rg -n -C 8 --glob '*.{ts,json,md,yml,yaml}' -e 'ghExecFile' -e 'gh version' -e 'gh cli' -e 'GitHub Enterprise' -e 'GitHub Enterprise Server' -e 'gh.*version' package.json src/main docs .github | sed -n '1,1600p'

Repository: stablyai/orca

Length of output: 42341


Web query:

official GitHub CLI source gh pr edit add-reviewer remove-reviewer GHES REST GraphQL implementation version

Result:

<source_evidence>
<source kind="find_in_page">
<title>cli/pkg/cmd/pr/edit/edit.go at trunk · cli/cli · GitHub</title>
<location>https://github.com/cli/cli/blob/trunk/pkg/cmd/pr/edit/edit.go</location>
<excerpt>citeturn2view2 [wordlim: 200] Crawled: today; Content type: text/html; Source: find({&quot;ref_id&quot;:&quot;turn1view0&quot;,&quot;pattern&quot;:&quot;reviewer&quot;}); Total lines: 2529
L1655: # Manage reviewers
L1656: 
L1657: $ gh pr edit 23 --add-reviewer monalisa,hubot --remove-reviewer myorg/team-name
L1658: 
L1659: # Re-request review
L1660: 
L1661: $ gh pr edit 23 --add-reviewer monalisa
L1662: 
L1663: # Request a review from GitHub Copilot
L1664: 
L1665: $ gh pr edit 23 --add-reviewer &quot;@copilot&quot;
L1666: 
L1667: # Manage assignees
L1668: 
L1669: $ gh pr edit 23 --add-assignee &quot;@me&quot; --remove-assignee monalisa,hubot
L1670: 
L1671: # Assign GitHub Copilot
L1672: 
L1673: $ gh pr edit 23 --add-assignee &quot;@copilot&quot;
L1674: # Manage projects and milestones
L1675: 
L1676: $ gh pr edit 23 --add-project &quot;Roadmap&quot; --remove-project v1,v2
L1677: 
L1678: $ gh pr edit 23 --milestone &quot;Version 1&quot;
L1679: 
L1680: $ gh pr edit 23 --remove-milestone
L1681: 
L1682: `),
L1683: 
L1765: &quot;specify only one of `--milestone` or `--remove-milestone`&quot;,
L1766: 
L1767: flags.Changed(&quot;milestone&quot;),
L1768: 
L1769: removeMilestone,
L1770: 
L1771: ); err != nil {
L1772: 
L1773: return err
L1774: 
L1775: }
L1776: 
L1777: if flags.Changed(&quot;title&quot;) {
L1778: 
L1779: opts.Editable.Title.Edited = true
L1780: 
L1781: }
L1782: 
L1783: if flags.Changed(&quot;body&quot;) {
L1784: 
L1785: opts.Editable.Body.Edited = true
L1786: 
L1787: }
L1788: 
L1789: if flags.Changed(&quot;base&quot;) {
L1790: 
L1791: opts.Editable.Base.Edited = true
L1792: 
L1793: }
L1794: 
L1795: if flags.Changed(&quot;add-reviewer&quot;) || flags.Changed(&quot;remove-reviewer&quot;) {
L1796: 
L1797: opts.Editable.Reviewers.Edited = true
L1798: 
L1799: }
L1800: if flags.Changed(&quot;add-assignee&quot;) || flags.Changed(&quot;remove-assignee&quot;) {
L1801: 
L1802: opts.Editable.Assignees.Edited = true
L1803: 
L1804: }
L1805: 
L1806: if flags.Changed(&quot;add-label&quot;) || flags.Changed(&quot;remove-label&quot;) {
L1807: 
L1808: opts.Editable.Labels.Edited = true
L1809: 
L1810: }
L1811: 
L1812: if flags.Changed(&quot;add-project&quot;) || flags.Changed(&quot;remove-project&quot;) {
L1813: 
L1814: opts.Editable.Projects.Edited = true
L1815: 
L1816: }
L1817: 
L1818: if flags.Changed(&quot;milestone&quot;) || removeMilestone {
L1819: 
L1820: opts.Editable.Milestone.Edited = true
L1821: 
L1822: // Note that when `--remove-milestone` is provided, the value of
L1823: // `opts.Editable.Milestone.Value` will automatically be empty,
L1824: 
L1825: // which results in milestone association removal. For reference,
L1826: 
L1827: // see the `Editable.MilestoneId` method.
L1828: 
L1829: }
L1830: 
L1831: var err error
L1832: 
L1833: opts.AttachEvent = attachments.BeginTelemetry(telemetry, cmd.CommandPath(), opts.AttachFlag.Count())
L1834: 
L1835: opts.Assets, err = opts.AttachFlag.UserAssets()
L1836: 
L1837: if err != nil {
L1838: 
L1839: return err
L1840: 
L1841: }
L1842: 
L1843: if !opts.Editable.Dirty() &amp;&amp; len(opts.Assets) == 0 {
L1844: 
L1845: opts.Interactive = true
L1846: 
L1847: }
L1848: 
L1849: if opts.Interactive &amp;&amp; !opts.IO.CanPrompt() {
L1850: return cmdutil.FlagErrorf(&quot;--title, --body, --reviewer, --assignee, --label, --project, or --milestone required when not running interactively&quot;)
L1851: 
L1852: }
L1853: 
L1854: if runF != nil {
L1855: 
L1856: return runF(opts)
L1857: 
L1858: }
L1859: 
L1860: return editRun(opts)
L1861: 
L1862: },
L1863: 
L1864: }
L1865: 
L1866: cmd.Flags().StringVarP(&amp;opts.Editable.Title.Value, &quot;title&quot;, &quot;t&quot;, &quot;&quot;, &quot;Set the new title.&quot;)
L1867: 
L1868: cmd.Flags().StringVarP(&amp;opts.Editable.Body.Value, &quot;body&quot;, &quot;b&quot;, &quot;&quot;, &quot;Set the new body.&quot;)
L1869: cmd.Flags().StringVarP(&amp;bodyFile, &quot;body-file&quot;, &quot;F&quot;, &quot;&quot;, &quot;Read body text from `file` (use \&quot;-\&quot; to read from standard input)&quot;)
L1870: 
L1871: cmd.Flags().StringVarP(&amp;opts.Editable.Base.Value, &quot;base&quot;, &quot;B&quot;, &quot;&quot;, &quot;Change the base `branch` for this pull request&quot;)
L1872: 
L1873: cmd.Flags().StringSliceVar(&amp;opts.Editable.Reviewers.Add, &quot;add-reviewer&quot;, nil, &quot;Add or re-request reviewers by their `login`. Use \&quot;@copilot\&quot; to request review from Copilot.&quot;)
L1874: cmd.Flags().StringSliceVar(&amp;opts.Editable.Reviewers.Remove, &quot;remove-reviewer&quot;, nil, &quot;Remove reviewers by their `login`. Use \&quot;@copilot\&quot; to remove review request from Copilot.&quot;)
L1875: 
L1876: cmd.Flags().StringSliceVar(&amp;opts.Editable.Assignees.Add, &quot;add-assignee&quot;, nil, &quot;Add assigned users by their `login`. Use \&quot;@me\&quot; to assign yourself, or \&quot;@copilot\&quot; to assign Copilot.&quot;)
L1877: cmd.Flags().StringSliceVar(&amp;opts.Editable.Assignees.Remove, &quot;remove-assignee&quot;, nil, &quot;Remove assigned users by their `login`. Use \&quot;@me\&quot; to unassign yourself, or \&quot;@copilot\&quot; to unassign Copilot.&quot;)
L1878: 
L1879: cmd.Flags().StringSliceVar(&amp;opts.Editable.Labels.Add, &quot;add-label&quot;, nil, &quot;Add labels by `name`&quot;)
L1880: 
L1881: cmd.Flags().StringSliceVar(&amp;opts.Editable.Labels.Remove, &quot;remove-label&quot;, nil, &quot;Remove labels by `name`&quot;)
L1887: cmd.Flags().BoolVar(&amp;removeMilestone, &quot;remove-milestone&quot;, false, &quot;Remove the milestone association from the pull request&quot;)
L1888: 
L1889: opts.AttachFlag = attachments.AddFlag(cmd)
L1890: 
L1891: _ = cmdutil.RegisterBranchCompletionFlags(f.GitClient, cmd, &quot;base&quot;)
L1892: 
L1893: for _, flagName := range []string{&quot;add-reviewer&quot;, &quot;remove-reviewer&quot;} {
L1894: 
L1895: _ = cmd.RegisterFlagCompletionFunc(flagName, func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
L1896: 
L1897: baseRepo, err := f.BaseRepo()
L1898: 
L1899: if err != nil {
L2326: // Replace @copilot with the Copilot reviewer login (only on github.com).
L2327: 
L2328: // Also use DefaultLogins (not Default display names) for computing the set.
L2329: 
L2330: var defaultLogins []string
L2331: 
L2332: // TODO ApiActorsSupported
L2333: 
L2334: if editable.ApiActorsSupported {
L2335: 
L2336: copilotReplacer := shared.NewCopilotReviewerReplacer()
L2337: 
L2338: add = copilotReplacer.ReplaceSlice(add)
L2339: 
L2340: remove = copilotReplacer.ReplaceSlice(remove)
L2341: 
L2342: defaultLogins = editable.Reviewers.DefaultLogins
L2343: 
L2344: } else {
</excerpt>
</source>
<source kind="open_page">
<title>cli/pkg/cmd/pr/edit/edit.go at trunk · cli/cli · GitHub</title>
<location>https://github.com/cli/cli/blob/trunk/pkg/cmd/pr/edit/edit.go</location>
<excerpt>citeturn1view0 [wordlim: 200] Crawled: today; Content type: text/html; Source: open({&quot;ref_id&quot;:&quot;https://github.com/cli/cli/blob/trunk/pkg/cmd/pr/edit/edit.go&quot;,&quot;lineno&quot;:null}); Total lines: 2529
L0: 【0†Skip to content】
L1: ## Navigation Menu
L2: 
L3: 【1†Sign in】
L4: 
L5: Appearance settings
L6: 
L7:   * Platform
L8: 
L9:     * AI CODE CREATION
L10:       * 【2†GitHub CopilotWrite better code with AI】
L11:       * 【3†GitHub Copilot appDirect agents from issue to merge】
L12:       * 【4†MCP RegistryIntegrate external tools】
L13: 
L14:     * DEVELOPER WORKFLOWS
L15:       * 【5†ActionsAutomate any workflow】
L16:       * 【6†CodespacesInstant dev environments】
L17:       * 【7†IssuesPlan and track work】
L18:       * 【8†Code ReviewManage code changes】
L19:       * 【9†Code QualityEnforce quality at merge】
L20:     * APPLICATION SECURITY
L21:       * 【10†GitHub Advanced SecurityFind and fix vulnerabilities】
L22:       * 【11†Code securitySecure your code as you build】
L23:       * 【12†Secret protectionStop leaks before they start】
L24: 
L25:     * EXPLORE
L26:       * 【13†Why GitHub】
L27:       * 【14†Documentation†docs.github.com】
L28:       * 【15†Blog†github.blog】
L29:       * 【16†Changelog†github.blog】
L30:       * 【17†Marketplace】
L31: 
L32: 【18†View all features】
L33: 
L34:   * Solutions
L35:     * BY COMPANY SIZE
L36:       * 【19†Enterprises】
L37:       * 【20†Small and medium teams】
L38:       * 【21†Startups】
L39:       * 【22†Nonprofits】
L40: 
L41:     * BY USE CASE
L42:       * 【23†App Modernization】
L43:       * 【24†DevSecOps】
L44:       * 【25†DevOps】
L45:       * 【26†CI/CD】
L46:       * 【27†View all use cases】
L47: 
L48:     * BY INDUSTRY
L49:       * 【28†Healthcare】
L50:       * 【29†Financial services】
L51:       * 【30†Manufacturing】
L52:       * 【31†Government】
L53:       * 【32†See all industries】
L54: 
L55: 【33†View all solutions】
L56: 
L57:   * Resources
L58:     * EXPLORE BY TOPIC
L59:       * 【34†AI】
L60:       * 【35†Software Development】
L61:       * 【36†DevOps】
L62:       * 【37†Security】
L63:       * 【38†View all topics】
L64: 
L65:     * EXPLORE BY TYPE
L66:       * 【39†Customer stories】
L67:       * 【40†Events &amp; webinars】
L68:       * 【41†Ebooks &amp; reports】
L69:       * 【42†Business insights】
L70:       * 【43†GitHub Skills†skills.github.com】
L71:     * SUPPORT &amp; SERVICES
L72:       * 【14†Documentation†docs.github.com】
L73:       * 【44†Customer support†support.github.com】
L74:       * 【45†Community forum】
L75:       * 【46†Trust center】
L76:       * 【47†Partners】
L77: 
L78: 【48†View all resources】
L79: 
L80:   * Open Source
L81: 
L82:     * COMMUNITY
L83:       * 【49†GitHub SponsorsFund open source developers】
L84:     * PROGRAMS
L85:       * 【50†Security Lab†securitylab.github.com】
L86:       * 【51†Maintainer Community†maintainers.github.com】
L87:       * 【52†GitHub Stars†stars.github.com】
L88:       * 【53†Archive Program†archiveprogram.github.com】
L89: 
L90:     * REPOSITORIES
L91:       * 【54†Topics】
L92:       * 【55†Trending】
L93:       * 【56†Collections】
L94: 
L95:   * Enterprise
L96: 
L97:     * ENTERPRISE SOLUTIONS
L98:       * 【19†Enterprise platformAI-powered developer platform】
L99:     * AVAILABLE ADD-ONS
L100:       * 【10†GitHub Advanced SecurityEnterprise-grade security features】
L101:       * 【57†Copilot for BusinessEnterprise-grade AI features】
L102:       * 【58†Premium SupportEnterprise-grade 24/7 support】
L103: 
L104:   * 【59†Pricing】
L105: 
L106: Search`/`
L107: 
L108: 【1†Sign in】
L109: 
L110: 【60†Sign up】
L111: 
L112: Appearance settings
L113: You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert
L114: 
L115:   1. 【61†cli】
L116:   2. 【62†cli】
L117: ## Repository navigation
L118: 
L119:   *   * 【62†Code】
L120:   * 【63†Issues1k (1k)】
L121:   * 【64†Pull requests60 (60)】
L122:   * 【65†Discussions】
L123:   * 【66†Actions】
L124:   * 【67†Projects】
L125:   * 【68†Security and quality17 (17)】
L126:   * 【69†Insights】
L127: 
L128: More items
L129: 
L130: ## Files Expand file tree
L131: 
L132: trunk
L133: 
L134: ## Breadcrumbs
L135: 
L136:   1. 【70†cli】
L137:   2. /【71†pkg】
L138:   3. /【72†cmd】
L139:   4. /【73†pr】
L140:   5. /【74†edit】
L141: 
L142: /
L143: 
L144: # edit.go
L145: 
L146: Copy path
L147: 
L148: [Input: Go to file]
L149: 
L150: Blame More file actions
L151: 
L152: Blame More file actions
L153: 
L154: ## Latest commit
L155: 
L156: 
L157: 
L158: ## History
L159: 
L160: History
L161: 
L162: trunk
L163: ## Breadcrumbs
L164: 
L165:   1. 【70†cli】
L166:   2. /【71†pkg】
L167:   3. /【72†cmd】
L168:   4. /【73†pr】
L169:   5. /【74†edit】
L170: 
L171: /
L172: 
L173: # edit.go
L174: 
L175: Copy path
L176: 
L177: Top
L178: ## File metadata and controls
L179: 
L180:   * Code
L181: 
L182:   * Blame
L183: 
L184: 643 lines (549 loc) · 21.6 KB
L185: 
L186: 【75†Raw】
L187: 
L188: Copy raw file
L189: 
L190: Download raw file
L191: 
L192: Open symbols panel
L193: 
L194: Edit and raw actions
L195: 
L196: 1
L197: 
L198: 2
L199: 
L200: 3
L201: 
L202: 4
L203: 
L204: 5
L205: 
L206: 6
L207: 
L208: 7
L209: 
L210: 8
L211: 
L212: 9
L213: 
L214: 10
L215: 
L216: 11
L217: 
L218: 12
L219: 
L220: 13
L221: 
L222: 14
L223: 
L224: 15
L225: 
L226: 16
L227: 
L228: 17
L229: 
L230: 18
L231: 
L232: 19
L233: 
L234: 20
L235: 
L236: 21
L237: 
L238: 22
L239: 
L240: 23
L241: 
L242: 24
L243: 
L244: 25
L245: 
L246: 26
L247: 
L248: 27
L249: 
L250: 28
L251: 
L252: 29
L253: 
L254: 30
L255: 
L256: 31
L257: 
L258: 32
L259: 
L260: 33
L261: 
L262: 34
L263: 
L264: 35
L265: 
L266: 36
L267: 
L268: 37
L269: 
L270: 38
L271: 
L272: 39
L273: 
L274: 40
L275: 
L276: 41
L277: 
L278: 42
L279: 
L280: 43
L281: 
L282: 44
L283: 
L284: 45
L285: 
L286: 46
L287: 
L288: 47
L289: 
L290: 48
L291: 
L292: 49
L293: 
L294: 50
L295: 
L296: 51
L297: 
L298: 52
L299: 
L300: 53
L301: 
L302: 54
L303: 
L304: 55
L305: 
L306: 56
L307: 
L308: 57
L309: 
L310: 58
L311: 
L312: 59
L313: 
L314: 60
L315: 
L316: 61
L317: 
L318: 62
L319: 
L320: 63
L321: 
L322: 64
L323: 
L324: 65
L325: 
L326: 66
L327: 
L328: 67
L329: 
L330: 68
L331: 
L332: 69
L333: 
L334: 70
L335: 
L336: 71
L337: 
L338: 72
L339: 
L340: 73
L341: 
L342: 74
L343: 
L344: 75
L345: 
L346: 76
L347: 
L348: 77
L349: 
L350: 78
L351: 
L352: 79
L353: 
L354: 80
L355: 
L356: 81
L357: 
L358: 82
L359: 
L360: 83
L361: 
L362: 84
L363: 
L364: 85
L365: 
L366: 86
L367: 
L368: 87
L369: 
L370: 88
L371: 89
L372: 
L373: 90
L374: 
L375: 91
L376: 
L377: 92
L378: 
L379: 93
L380: 
L381: 94
L382: 
L383: 95
L384: 
L385: 96
L386: 
L387: 97
L388: 
L389: 98
L390: 
L391: 99
L392: 
L393: 100
L394: 
L395: 101
L396: 
L397: 102
L398: 
L399: 103
L400: 
L401: 104
L402: 
L403: 105
L404: 
L405: 106
L406: 
L407: 107
L408: 
L409: 108
L410: 
L411: 109
L412: 
L413: 110
L414: 
L415: 111
L416: 
L417: 112
L418: 
L419: 113
L420: 
L421: 114
L422: 
L423: 115
L424: 
L425: 116
L426: 
L427: 117
L428: 
L429: 118
L430: 
L431: 119
L432: 
L433: 120
L434: 
L435: 121
L436: 
L437: 122
L438: 
L439: 123
L440: 
L441: 124
L442: 
L443: 125
L444: 
L445: 126
L446: 
L447: 127
L448: 
L449: 128
L450: 
L451: 129
L452: 
L453: 130
L454: 
L455: 131
L456: 
L457: 132
L458: 
L459: 133
L460: 
L461: 134
L462: 
L463: 135
L464: 
L465: 136
L466: 
L467: 137
L468: 
L469: 138
L470: 
L471: 139
L472: 
L473: 140
L474: 
L475: 141
L476: 
L477: 142
L478: 
L479: 143
L480: 
L481: 144
L482: 
L483: 145
L484: 
L485: 146
L486: 
L487: 147
L488: 
L489: 148
L490: 
L491: 149
L492: 
L493: 150
L494: 
L495: 151
L496: 
L497: 152
L498: 
L499: 153
L500: 
L501: 154
L502: 
L503: 155
L504: 
L505: 156
L506: 
L507: 157
L508: 
L509: 158
L510: 
L511: 159
L512: 
L513: 160
L514: 
L515: 161
L516: 
L517: 162
L518: 
L519: 163
L520: 
L521: 164
L522: 
L523: 165
L524: 
L525: 166
L526: 
L527: 167
L528: 
L529: 168
L530: 
L531: 169
L532: 
L533: 170
L534: 
L535: 171
L536: 
L537: 172
L538: 
L539: 173
L540: 
L541: 174
L542: 
L543: 175
L544: 
L545: 176
L546: 
L547: 177
L548: 
L549: 178
L550: 
L551: 179
L552: 
L553: 180
L554: 
L555: 181
L556: 
L557: 182
L558: 
L559: 183
L560: 
L561: 184
L562: 
L563: 185
L564: 
L565: 186
L566: 
L567: 187
L568: 
L569: 188
L570: 
L571: 189
L572: 
L573: 190
L574: 
L575: 191
L576: 
L577: 192
L578: 193
L579: 
L580: 194
L581: 
L582: 195
L583: 
L584: 196
L585: 
L586: 197
L587: 
L588: 198
L589: 
L590: 199
L591: 
L592: 200
L593: 
L594: 201
L595: 
L596: 202
L597: 
L598: 203
L599: 
L600: 204
L601: 
L602: 205
L603: 
L604: 206
L605: 
L606: 207
L607: 
L608: 208
L609: 
L610: 209
L611: 
L612: 210
L613: 
L614: 211
L615: 
L616: 212
L617: 
L618: 213
L619: 
L620: 214
L621: 
L622: 215
L623: 
L624: 216
L625: 
L626: 217
L627: 
L628: 218
L629: 
L630: 219
L631: 
L632: 220
L633: 
L634: 221
L635: 
L636: 222
L637: 
L638: 223
L639: 
L640: 224
L641: 
L642: 225
L643: 
L644: 226
L645: 
L646: 227
L647: 
L648: 228
L649: 
L650: 229
L651: 
L652: 230
L653: 
L654: 231
L655: 
L656: 232
L657: 
L658: 233
L659: 
L660: 234
L661: 
L662: 235
L663: 
L664: 236
L665: 
L666: 237
L667: 
L668: 238
L669: 
L670: 239
L671: 
L672: 240
L673: 
L674: 241
L675: 
L676: 242
L677: 
L678: 243
L679: 
L680: 244
L681: 
L682: 245
L683: 
L684: 246
L685: 
L686: 247
L687: 
L688: 248
L689: 
L690: 249
L691: 
L692: 250
L693: 
L694: 251
L695: 
L696: 252
L697: 
L698: 253
L699: 
L700: 254
L701: 
L702: 255
L703: 
L704: 256
L705: 
L706: 257
L707: 
L708: 258
L709: 
L710: 259
L711: 
L712: 260
L713: 
L714: 261
L715: 
L716: 262
L717: 
L718: 263
L719: 
L720: 264
L721: 
L722: 265
L723: 
L724: 266
L725: 
L726: 267
L727: 
L728: 268
L729: 
L730: 269
L731: 
L732: 270
L733: 
L734: 271
L735: 
L736: 272
L737: 
L738: 273
L739: 
L740: 274
L741: 
L742: 275
L743: 
L744: 276
L745: 
L746: 277
L747: 
L748: 278
L749: 
L750: 279
L751: 
L752: 280
L753: 
L754: 281
L755: 
L756: 282
L757: 
L758: 283
L759: 
L760: 284
L761: 
L762: 285
L763: 
L764: 286
L765: 
L766: 287
L767: 
L768: 288
L769: 
L770: 289
L771: 
L772: 290
L773: 
L774: 291
L775: 
L776: 292
L777: 
L778: 293
L779: 
L780: 294
L781: 295
L782: 
L783: 296
L784: 
L785: 297
L786: 
L787: 298
L788: 
L789: 299
L790: 
L791: 300
L792: 
L793: 301
L794: 
L795: 302
L796: 
L797: 303
L798: 
L799: 304
L800: 
L801: 305
L802: 
L803: 3…[truncated]</excerpt>
</source>
<source kind="open_page">
<title>GitHub - cli/cli: GitHub’s official command line tool · GitHub</title>
<location>https://github.com/cli/cli</location>
<excerpt>citeturn1view2 [wordlim: 200] Crawled: today; Content type: text/html; Source: open({&quot;ref_id&quot;:&quot;https://github.com/cli/cli&quot;,&quot;lineno&quot;:null}); Total lines: 401
L0: 【0†Skip to content】
L1: ## Navigation Menu
L2: 
L3: 【1†Sign in】
L4: 
L5: Appearance settings
L6: 
L7:   * Platform
L8: 
L9:     * AI CODE CREATION
L10:       * 【2†GitHub CopilotWrite better code with AI】
L11:       * 【3†GitHub Copilot appDirect agents from issue to merge】
L12:       * 【4†MCP RegistryIntegrate external tools】
L13: 
L14:     * DEVELOPER WORKFLOWS
L15:       * 【5†ActionsAutomate any workflow】
L16:       * 【6†CodespacesInstant dev environments】
L17:       * 【7†IssuesPlan and track work】
L18:       * 【8†Code ReviewManage code changes】
L19:       * 【9†Code QualityEnforce quality at merge】
L20:     * APPLICATION SECURITY
L21:       * 【10†GitHub Advanced SecurityFind and fix vulnerabilities】
L22:       * 【11†Code securitySecure your code as you build】
L23:       * 【12†Secret protectionStop leaks before they start】
L24: 
L25:     * EXPLORE
L26:       * 【13†Why GitHub】
L27:       * 【14†Documentation†docs.github.com】
L28:       * 【15†Blog†github.blog】
L29:       * 【16†Changelog†github.blog】
L30:       * 【17†Marketplace】
L31: 
L32: 【18†View all features】
L33: 
L34:   * Solutions
L35:     * BY COMPANY SIZE
L36:       * 【19†Enterprises】
L37:       * 【20†Small and medium teams】
L38:       * 【21†Startups】
L39:       * 【22†Nonprofits】
L40: 
L41:     * BY USE CASE
L42:       * 【23†App Modernization】
L43:       * 【24†DevSecOps】
L44:       * 【25†DevOps】
L45:       * 【26†CI/CD】
L46:       * 【27†View all use cases】
L47: 
L48:     * BY INDUSTRY
L49:       * 【28†Healthcare】
L50:       * 【29†Financial services】
L51:       * 【30†Manufacturing】
L52:       * 【31†Government】
L53:       * 【32†See all industries】
L54: 
L55: 【33†View all solutions】
L56: 
L57:   * Resources
L58:     * EXPLORE BY TOPIC
L59:       * 【34†AI】
L60:       * 【35†Software Development】
L61:       * 【36†DevOps】
L62:       * 【37†Security】
L63:       * 【38†View all topics】
L64: 
L65:     * EXPLORE BY TYPE
L66:       * 【39†Customer stories】
L67:       * 【40†Events &amp; webinars】
L68:       * 【41†Ebooks &amp; reports】
L69:       * 【42†Business insights】
L70:       * 【43†GitHub Skills†skills.github.com】
L71:     * SUPPORT &amp; SERVICES
L72:       * 【14†Documentation†docs.github.com】
L73:       * 【44†Customer support†support.github.com】
L74:       * 【45†Community forum】
L75:       * 【46†Trust center】
L76:       * 【47†Partners】
L77: 
L78: 【48†View all resources】
L79: 
L80:   * Open Source
L81: 
L82:     * COMMUNITY
L83:       * 【49†GitHub SponsorsFund open source developers】
L84:     * PROGRAMS
L85:       * 【50†Security Lab†securitylab.github.com】
L86:       * 【51†Maintainer Community†maintainers.github.com】
L87:       * 【52†GitHub Stars†stars.github.com】
L88:       * 【53†Archive Program†archiveprogram.github.com】
L89: 
L90:     * REPOSITORIES
L91:       * 【54†Topics】
L92:       * 【55†Trending】
L93:       * 【56†Collections】
L94: 
L95:   * Enterprise
L96: 
L97:     * ENTERPRISE SOLUTIONS
L98:       * 【19†Enterprise platformAI-powered developer platform】
L99:     * AVAILABLE ADD-ONS
L100:       * 【10†GitHub Advanced SecurityEnterprise-grade security features】
L101:       * 【57†Copilot for BusinessEnterprise-grade AI features】
L102:       * 【58†Premium SupportEnterprise-grade 24/7 support】
L103: 
L104:   * 【59†Pricing】
L105: 
L106: Search`/`
L107: 
L108: 【1†Sign in】
L109: 
L110: 【60†Sign up】
L111: 
L112: Appearance settings
L113: You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert
L114: 
L115:   1. 【61†cli】
L116:   2. 【62†cli】
L117: ## Repository navigation
L118: 
L119:   *   * 【62†Code】
L120:   * 【63†Issues1k (1k)】
L121:   * 【64†Pull requests59 (59)】
L122:   * 【65†Discussions】
L123:   * 【…[truncated]</excerpt>
</source>
<source kind="open_page">
<title>cli/pkg/cmd/pr/edit/edit.go at trunk · cli/cli · GitHub</title>
<location>https://github.com/cli/cli/blob/trunk/pkg/cmd/pr/edit/edit.go</location>
<excerpt>citeturn3view0 [wordlim: 200] Crawled: today; Content type: text/html; Source: open({&quot;ref_id&quot;:&quot;turn1view0&quot;,&quot;lineno&quot;:2360}); Total lines: 2529
L2253: // so that updating the PR later can resolve the team ID.
L2254: 
L2255: if team, ok := c.(api.ReviewerTeam); ok {
L2256: 
L2257: editable.Metadata.Teams = append(editable.Metadata.Teams, api.OrgTeam{
L2258: 
L2259: ID: &quot;&quot;, // ID not needed for REST API reviewer mutations
L2260: 
L2261: Slug: team.Slug(),
L2262: 
L2263: })
L2264: 
L2265: }
L2266: 
L2267: }
L2268: 
L2269: return prompter.MultiSelectSearchResult{
L2270: 
L2271: Keys: keys,
L2272: 
L2273: Labels: labels,
L2274: 
L2275: MoreResults: moreResults,
L2276: 
L2277: Err: nil,
L2278: 
L2279: }
L2280: 
L2281: }
L2282: 
L2283: return searchFunc
L2284: 
L2285: }
L2286: func updatePullRequest(httpClient *http.Client, repo ghrepo.Interface, id string, number int, editable shared.Editable) error {
L2287: 
L2288: var wg errgroup.Group
L2289: 
L2290: wg.Go(func() error {
L2291: 
L2292: return shared.UpdateIssue(httpClient, repo, id, true, editable)
L2293: 
L2294: })
L2295: 
L2296: if editable.Reviewers.Edited {
L2297: 
L2298: wg.Go(func() error {
L2299: 
L2300: return updatePullRequestReviews(httpClient, repo, id, number, editable)
L2301: 
L2302: })
L2303: 
L2304: }
L2305: 
L2306: return wg.Wait()
L2307: 
L2308: }
L2309: func updatePullRequestReviews(httpClient *http.Client, repo ghrepo.Interface, prID string, number int, editable shared.Editable) error {
L2310: 
L2311: if !editable.Reviewers.Edited {
L2312: 
L2313: return nil
L2314: 
L2315: }
L2316: 
L2317: client := api.NewClientFromHTTP(httpClient)
L2318: 
L2319: // Rebuild the Value slice from non-interactive flag input.
L2320: 
L2321: if len(editable.Reviewers.Add) != 0 || len(editable.Reviewers.Remove) != 0 {
L2322: 
L2323: add := editable.Reviewers.Add
L2324: 
L2325: remove := editable.Reviewers.Remove
L2326: // Replace @copilot with the Copilot reviewer login (only on github.com).
L2327: 
L2328: // Also use DefaultLogins (not Default display names) for computing the set.
L2329: 
L2330: var defaultLogins []string
L2331: 
L2332: // TODO ApiActorsSupported
L2333: 
L2334: if editable.ApiActorsSupported {
L2335: 
L2336: copilotReplacer := shared.NewCopilotReviewerReplacer()
L2337: 
L2338: add = copilotReplacer.ReplaceSlice(add)
L2339: 
L2340: remove = copilotReplacer.ReplaceSlice(remove)
L2341: 
L2342: defaultLogins = editable.Reviewers.DefaultLogins
L2343: 
L2344: } else {
L2345: // On GHES, Default already contains logins (no display name distinction)
L2346: 
L2347: defaultLogins = editable.Reviewers.Default
L2348: 
L2349: }
L2350: 
L2351: s := set.NewStringSet()
L2352: 
L2353: s.AddValues(add)
L2354: 
L2355: s.AddValues(defaultLogins)
L2356: 
L2357: s.RemoveValues(remove)
L2358: 
L2359: editable.Reviewers.Value = s.ToSlice()
L2360: 
L2361: }
L2362: 
L2363: // On github.com, use the new GraphQL mutation which supports bots.
L2364: 
L2365: // On GHES, fall back to REST API.
L2366: 
L2367: // TODO ApiActorsSupported
L2368: 
L2369: if editable.ApiActorsSupported {
L2370: 
L2371: return updatePullRequestReviewsGraphQL(client, repo, prID, editable)
L2372: 
L2373: }
L2374: return updatePullRequestReviewsREST(client, repo, number, editable)
L2375: 
L2376: }
L2377: 
L2378: // updatePullRequestReviewsGraphQL uses the RequestReviewsByLogin mutation.
L2379: 
L2380: // This mutation replaces the entire reviewer set (union: false).
L2381: 
L2382: func updatePullRequestReviewsGraphQL(client *api.Client, repo ghrepo.Interface, prID string, editable shared.Editable) error {
L2383: 
L2384: users, bots, teams := partitionReviewersByType(editable.Reviewers.Value)
L2385: 
L2386: return api.RequestReviewsByLogin(client, repo, prID, users, bots, teams, false)
L2387: 
L2388: }
L2389: // updatePullRequestReviewsREST uses the REST API to add/remove reviewers.
L2390: 
L2391: // This is the legacy path for GHES compatibility.
L2392: 
L2393: func upda…[truncated]</excerpt>
</source>
<source kind="open_page">
<title>cli/api/queries_pr.go at trunk · cli/cli · GitHub</title>
<location>https://github.com/cli/cli/blob/trunk/api/queries_pr.go</location>
<excerpt>citeturn3view2 [wordlim: 200] Crawled: today; Content type: text/html; Source: open({&quot;ref_id&quot;:&quot;https://github.com/cli/cli/blob/trunk/api/queries_pr.go&quot;,&quot;lineno&quot;:null}); Total lines: 3582
L0: 【0†Skip to content】
L1: ## Navigation Menu
L2: 
L3: 【1†Sign in】
L4: 
L5: Appearance settings
L6: 
L7:   * Platform
L8: 
L9:     * AI CODE CREATION
L10:       * 【2†GitHub CopilotWrite better code with AI】
L11:       * 【3†GitHub Copilot appDirect agents from issue to merge】
L12:       * 【4†MCP RegistryIntegrate external tools】
L13: 
L14:     * DEVELOPER WORKFLOWS
L15:       * 【5†ActionsAutomate any workflow】
L16:       * 【6†CodespacesInstant dev environments】
L17:       * 【7†IssuesPlan and track work】
L18:       * 【8†Code ReviewManage code changes】
L19:       * 【9†Code QualityEnforce quality at merge】
L20:     * APPLICATION SECURITY
L21:       * 【10†GitHub Advanced SecurityFind and fix vulnerabilities】
L22:       * 【11†Code securitySecure your code as you build】
L23:       * 【12†Secret protectionStop leaks before they start】
L24: 
L25:     * EXPLORE
L26:       * 【13†Why GitHub】
L27:       * 【14†Documentation†docs.github.com】
L28:       * 【15†Blog†github.blog】
L29:       * 【16†Changelog†github.blog】
L30:       * 【17†Marketplace】
L31: 
L32: 【18†View all features】
L33: 
L34:   * Solutions
L35:     * BY COMPANY SIZE
L36:       * 【19†Enterprises】
L37:       * 【20†Small and medium teams】
L38:       * 【21†Startups】
L39:       * 【22†Nonprofits】
L40: 
L41:     * BY USE CASE
L42:       * 【23†App Modernization】
L43:       * 【24†DevSecOps】
L44:       * 【25†DevOps】
L45:       * 【26†CI/CD】
L46:       * 【27†View all use cases】
L47: 
L48:     * BY INDUSTRY
L49:       * 【28†Healthcare】
L50:       * 【29†Financial services】
L51:       * 【30†Manufacturing】
L52:       * 【31†Government】
L53:       * 【32†See all industries】
L54: 
L55: 【33†View all solutions】
L56: 
L57:   * Resources
L58:     * EXPLORE BY TOPIC
L59:       * 【34†AI】
L60:       * 【35†Software Development】
L61:       * 【36†DevOps】
L62:       * 【37†Security】
L63:       * 【38†View all topics】
L64: 
L65:     * EXPLORE BY TYPE
L66:       * 【39†Customer stories】
L67:       * 【40†Events &amp; webinars】
L68:       * 【41†Ebooks &amp; reports】
L69:       * 【42†Business insights】
L70:       * 【43†GitHub Skills†skills.github.com】
L71:     * SUPPORT &amp; SERVICES
L72:       * 【14†Documentation†docs.github.com】
L73:       * 【44†Customer support†support.github.com】
L74:       * 【45†Community forum】
L75:       * 【46†Trust center】
L76:       * 【47†Partners】
L77: 
L78: 【48†View all resources】
L79: 
L80:   * Open Source
L81: 
L82:     * COMMUNITY
L83:       * 【49†GitHub SponsorsFund open source developers】
L84:     * PROGRAMS
L85:       * 【50†Security Lab†securitylab.github.com】
L86:       * 【51†Maintainer Community†maintainers.github.com】
L87:       * 【52†GitHub Stars†stars.github.com】
L88:       * 【53†Archive Program†archiveprogram.github.com】
L89: 
L90:     * REPOSITORIES
L91:       * 【54†Topics】
L92:       * 【55†Trending】
L93:       * 【56†Collections】
L94: 
L95:   * Enterprise
L96: 
L97:     * ENTERPRISE SOLUTIONS
L98:       * 【19†Enterprise platformAI-powered developer platform】
L99:     * AVAILABLE ADD-ONS
L100:       * 【10†GitHub Advanced SecurityEnterprise-grade security features】
L101:       * 【57†Copilot for BusinessEnterprise-grade AI features】
L102:       * 【58†Premium SupportEnterprise-grade 24/7 support】
L103: 
L104:   * 【59†Pricing】
L105: 
L106: Search`/`
L107: 
L108: 【1†Sign in】
L109: 
L110: 【60†Sign up】
L111: 
L112: Appearance settings
L113: You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert
L114: 
L115:   1. 【61†cli】
L116:   2. 【62†cli】
L117: ## Repository navigation
L118: 
L119:   *   * 【62†Code】
L120:   * 【63†Issues1k (1k)】
L121:   * 【64†Pull requests60 (60)】
L122:   …[truncated]</excerpt>
</source>
<omitted_sources count="30">Additional source records were omitted from this bounded result.</omitted_sources>
</source_evidence>

Citations:

- 1: https://github.com/cli/cli
- 2: https://github.com/cli/cli/blob/trunk/pkg/cmd/pr/edit/edit.go
- 3: https://github.com/cli/cli/blob/trunk/pkg/cmd/pr/edit/edit.go

Script executed:

set -o pipefail
printf '%s\n' '--- breaker implementation ---'
nl -ba src/main/git/gh-rate-limit-breaker.ts | sed -n '1,280p'
printf '%s\n' '--- reviewer caller ---'
nl -ba src/main/github/client/update/pr-reviewers.ts | sed -n '1,180p'
printf '%s\n' '--- project-view mutations ---'
nl -ba src/main/github/project-view/mutations.ts | sed -n '1,260p'
printf '%s\n' '--- issue update ---'
nl -ba src/main/github/issue-update.ts | sed -n '1,220p'
printf '%s\n' '--- runner rate-limit integration ---'
rg -n -C 18 --glob '*.ts' -e 'registerGhRateLimitResetProbe' -e 'notifyGhPrimaryRateLimit' -e 'classifyGhRateLimitBucket' -e 'isGhRateLimitProbe' -e 'getGhRateLimitBlockedUntilMs' src/main

Repository: stablyai/orca

Length of output: 42634


Web query:

official cli/cli source issue close reopen GHES REST GraphQL implementation updateIssue state command

Result:

<source_evidence>
<source kind="open_page">
<title></title>
<location>https://raw.githubusercontent.com/cli/cli/trunk/pkg/cmd/issue/close/close.go</location>
<excerpt>citeturn1view2 [wordlim: 200] Crawled: today; Content type: text/plain; Source: open({&quot;ref_id&quot;:&quot;https://raw.githubusercontent.com/cli/cli/trunk/pkg/cmd/issue/close/close.go&quot;,&quot;lineno&quot;:null}); Total lines: 201
L0: package close
L1: 
L2: import (
L3: 	&quot;fmt&quot;
L4: 	&quot;net/http&quot;
L5: 
L6: 	&quot;github.com/MakeNowJust/heredoc&quot;
L7: 	&quot;github.com/cli/cli/v2/api&quot;
L8: 	&quot;github.com/cli/cli/v2/internal/ghrepo&quot;
L9: 	&quot;github.com/cli/cli/v2/pkg/cmd/issue/shared&quot;
L10: 	prShared &quot;github.com/cli/cli/v2/pkg/cmd/pr/shared&quot;
L11: 	&quot;github.com/cli/cli/v2/pkg/cmdutil&quot;
L12: 	&quot;github.com/cli/cli/v2/pkg/iostreams&quot;
L13: 	&quot;github.com/shurcooL/githubv4&quot;
L14: 	&quot;github.com/spf13/cobra&quot;
L15: )
L16: type CloseOptions struct {
L17: 	HttpClient func() (*http.Client, error)
L18: 	IO         *iostreams.IOStreams
L19: 	BaseRepo   func() (ghrepo.Interface, error)
L20: 
L21: 	IssueNumber int
L22: 	Comment     string
L23: 	Reason      string
L24: 	DuplicateOf string
L25: }
L26: 
L27: func NewCmdClose(f *cmdutil.Factory, runF func(*CloseOptions) error) *cobra.Command {
L28: 	opts := &amp;CloseOptions{
L29: 		IO:         f.IOStreams,
L30: 		HttpClient: f.HttpClient,
L31: 	}
L32: 	cmd := &amp;cobra.Command{
L33: 		Use:   &quot;close {&lt;number&gt; | &lt;url&gt;}&quot;,
L34: 		Short: &quot;Close issue&quot;,
L35: 		Example: heredoc.Doc(`
L36: 			# Close issue
L37: 			$ gh issue close 123
L38: 
L39: 			# Close issue and add a closing comment
L40: 			$ gh issue close 123 --comment &quot;Closing this issue&quot;
L41: 
L42: 			# Close issue as a duplicate of issue #456
L43: 			$ gh issue close 123 --duplicate-of 456
L44: 			# Close issue as not planned
L45: 			$ gh issue close 123 --reason &quot;not planned&quot;
L46: 		`),
L47: 		Args: cobra.ExactArgs(1),
L48: 		RunE: func(cmd *cobra.Command, args []string) error {
L49: 			issueNumber, baseRepo, err := shared.ParseIssueFromArg(args[0])
L50: 			if err != nil {
L51: 				return err
L52: 			}
L53: 			// If the args provided the base repo then use that directly.
L54: 			if baseRepo, present := baseRepo.Value(); present {
L55: 				opts.BaseRepo = func() (ghrepo.Interface, error) {
L56: 					return baseRepo, nil
L57: 				}
L58: 			} else {
L59: 				// support `-R, --repo` override
L60: 				opts.BaseRepo = f.BaseRepo
L61: 			}
L62: 			opts.IssueNumber = issueNumber
L63: 			if opts.DuplicateOf != &quot;&quot; {
L64: 				if opts.Reason == &quot;&quot; {
L65: 					opts.Reason = &quot;duplicate&quot;
L66: 				} else if opts.Reason != &quot;duplicate&quot; {
L67: 					return cmdutil.FlagErrorf(&quot;`--duplicate-of` can only be used with `--reason duplicate`&quot;)
L68: 				}
L69: 			}
L70: 
L71: 			if runF != nil {
L72: 				return runF(opts)
L73: 			}
L74: 			return closeRun(opts)
L75: 		},
L76: 	}
L77: 	cmd.Flags().StringVarP(&amp;opts.Comment, &quot;comment&quot;, &quot;c&quot;, &quot;&quot;, &quot;Leave a closing comment&quot;)
L78: 	cmdutil.StringEnumFlag(cmd, &amp;opts.Reason, &quot;reason&quot;, &quot;r&quot;, &quot;&quot;, []string{&quot;completed&quot;, &quot;not planned&quot;, &quot;duplicate&quot;}, &quot;Reason for closing&quot;)
L79: 	cmd.Flags().StringVar(&amp;opts.DuplicateOf, &quot;duplicate-of&quot;, &quot;&quot;, &quot;Mark as duplicate of another issue by number or URL&quot;)
L80: 
L81: 	return cmd
L82: }
L83: func closeRun(opts *CloseOptions) error {
L84: 	cs := opts.IO.ColorScheme()
L85: 	closeReason := opts.Reason
L86: 	if opts.DuplicateOf != &quot;&quot; {
L87: 		if closeReason == &quot;&quot; {
L88: 			closeReason = &quot;duplicate&quot;
L89: 		} else if closeReason != &quot;duplicate&quot; {
L90: 			return cmdutil.FlagErrorf(&quot;`--duplicate-of` can only be used with `--reason duplicate`&quot;)
L91: 		}
L92: 	}
L93: 
L94: 	httpClient, err := opts.HttpClient()
L95: 	if err != nil {
L96: 		return err
L97: 	}
L98: 
L99: 	baseRepo, err := opts.BaseRepo()
L100: 	if err != nil {
L101: 		return err
L102: 	}
L103: 	issue, err := shared.FindIssueOrPR(httpClient, baseRepo, opts.IssueNumber, []string{&quot;id&quot;, &quot;number&quot;, &quot;title&quot;, &quot;state&quot;})
L104: 	if err != nil {
L105: 		return err
L106: 	}
L107: 
L108: 	if issue.State == &quot;CLOSED&quot; {
L109: 		fmt.Fprintf(opts.IO.ErrOut, &quot;%s Issue %s#%d (%s) is already closed\n&quot;, cs.Yellow(&quot;!&quot;), ghrepo.FullName(baseRepo), issue.Number, issue.Title)
L110: 		return nil
L111: 	}
L112: 	var duplicateIssueID string
L113: 	if opts.DuplicateOf != &quot;&quot; {
L114: 		if issue.IsPullRequest() {
L115: 			return cmdutil.FlagErrorf(&quot;`--duplicate-of` is only supported for issues&quot;)
L116: 		}
L117: 		duplicateIssueNumber, duplicateRepo, err := shared.ParseIssueFromArg(opts.DuplicateOf)
L118: 		if err != nil {
L119: 			return cmdutil.FlagErrorf(&quot;invalid value for `--duplicate-of`: %v&quot;, err)
L120: 		}
L121: 		duplicateIssueRepo := baseRepo
L122: 		if parsedRepo, present := duplicateRepo.Value(); present {
L123: 			duplicateIssueRepo = parsedRepo
L124: 		}
L125: 		if ghrepo.IsSame(baseRepo, duplicateIssueRepo) &amp;&amp; issue.Number == duplicateIssueNumber {
L126: 			return cmdutil.FlagErrorf(&quot;`--duplicate-of` cannot reference the current issue&quot;)
L127: 		}
L128: 		duplicateIssue, err := shared.FindIssueOrPR(httpClient, duplicateIssueRepo, duplicateIssueNumber, []string{&quot;id&quot;})
L129: 		if err != nil {
L130: 			return err
L131: 		}
L132: 		if duplicateIssue.IsPullRequest() {
L133: 			return cmdutil.FlagErrorf(&quot;`--duplicate-of` must reference an issue&quot;)
L134: 		}
L135: 		duplicateIssueID = duplicateIssue.ID
L136: 	}
L137: 	if opts.Comment != &quot;&quot; {
L138: 		commentOpts := &amp;prShared.CommentableOptions{
L139: 			Body:       opts.Comment,
L140: 			HttpClient: opts.HttpClient,
L141: 			InputType:  prShared.InputTypeInline,
L142: 			Quiet:      true,
L143: 			RetrieveCommentable: func() (prShared.Commentable, ghrepo.Interface, error) {
L144: 				return issue, baseRepo, nil
L145: 			},
L146: 		}
L147: 		err := prShared.CommentableRun(commentOpts)
L148: 		if err != nil {
L149: 			return err
L150: 		}
L151: 	}
L152: 	err = apiClose(httpClient, baseRepo, issue, closeReason, duplicateIssueID)
L153: 	if err != nil {
L154: 		return err
L155: 	}
L156: 
L157: 	fmt.Fprintf(opts.IO.ErrOut, &quot;%s Closed issue %s#%d (%s)\n&quot;, cs.SuccessIconWithColor(cs.Red), ghrepo.FullName(baseRepo), issue.Number, issue.Title)
L158: 
L159: 	return nil
L160: }
L161: 
L162: func apiClose(httpClient *http.Client, repo ghrepo.Interface, issue *api.Issue, reason string, duplicateIssueID string) error {
L163: 	if issue.IsPullRequest() {
L164: 		return api.PullRequestClose(httpClient, repo, issue.ID)
L165: 	}
L166: 	switch reason {
L167: 	case &quot;&quot;:
L168: 		// If no reason is specified do not set it.
L169: 	case &quot;not planned&quot;:
L170: 		reason = &quot;NOT_PLANNED&quot;
L171: 	case &quot;duplicate&quot;:
L172: 		reason = &quot;DUPLICATE&quot;
L173: 	default:
L174: 		reason = &quot;COMPLETED&quot;
L175: 	}
L176: 
L177: 	var mutation struct {
L178: 		CloseIssue struct {
L179: 			Issue struct {
L180: 				ID githubv4.ID
L181: 			}
L182: 		} `graphql:&quot;closeIssue(input: $input)&quot;`
L183: 	}
L184: 
L185: 	variables := map[string]any{
L186: 		&quot;input&quot;: CloseIssueInput{
L187: 			IssueID:          issue.ID,
L188: 			StateReason:      reason,
L189: 			DuplicateIssueID: duplicateIssueID,
L190: 		},
L191: 	}
L192: 	gql := api.NewClientFromHTTP(httpClient)
L193: 	return gql.Mutate(repo.RepoHost(), &quot;IssueClose&quot;, &amp;mutation, variables)
L194: }
L195: 
L196: type CloseIssueInput struct {
L197: 	IssueID          string `json:&quot;issueId&quot;`
L198: 	StateReason      string `json:&quot;stateReason,omitempty&quot;`
L199: 	DuplicateIssueID string `json:&quot;duplicateIssueId,omitempty&quot;`
L200: }
</excerpt>
</source>
<source kind="open_page">
<title></title>
<location>https://raw.githubusercontent.com/cli/cli/trunk/pkg/cmd/issue/reopen/reopen.go</location>
<excerpt>citeturn1view3 [wordlim: 200] Crawled: last week; Content type: text/plain; Source: open({&quot;ref_id&quot;:&quot;https://raw.githubusercontent.com/cli/cli/trunk/pkg/cmd/issue/reopen/reopen.go&quot;,&quot;lineno&quot;:null}); Total lines: 131
L0: package reopen
L1: 
L2: import (
L3: 	&quot;fmt&quot;
L4: 	&quot;net/http&quot;
L5: 
L6: 	&quot;github.com/cli/cli/v2/api&quot;
L7: 	&quot;github.com/cli/cli/v2/internal/gh&quot;
L8: 	&quot;github.com/cli/cli/v2/internal/ghrepo&quot;
L9: 	&quot;github.com/cli/cli/v2/pkg/cmd/issue/shared&quot;
L10: 	prShared &quot;github.com/cli/cli/v2/pkg/cmd/pr/shared&quot;
L11: 	&quot;github.com/cli/cli/v2/pkg/cmdutil&quot;
L12: 	&quot;github.com/cli/cli/v2/pkg/iostreams&quot;
L13: 	&quot;github.com/shurcooL/githubv4&quot;
L14: 	&quot;github.com/spf13/cobra&quot;
L15: )
L16: type ReopenOptions struct {
L17: 	HttpClient func() (*http.Client, error)
L18: 	Config     func() (gh.Config, error)
L19: 	IO         *iostreams.IOStreams
L20: 	BaseRepo   func() (ghrepo.Interface, error)
L21: 
L22: 	IssueNumber int
L23: 	Comment     string
L24: }
L25: 
L26: func NewCmdReopen(f *cmdutil.Factory, runF func(*ReopenOptions) error) *cobra.Command {
L27: 	opts := &amp;ReopenOptions{
L28: 		IO:         f.IOStreams,
L29: 		HttpClient: f.HttpClient,
L30: 		Config:     f.Config,
L31: 	}
L32: 	cmd := &amp;cobra.Command{
L33: 		Use:   &quot;reopen {&lt;number&gt; | &lt;url&gt;}&quot;,
L34: 		Short: &quot;Reopen issue&quot;,
L35: 		Args:  cobra.ExactArgs(1),
L36: 		RunE: func(cmd *cobra.Command, args []string) error {
L37: 			issueNumber, baseRepo, err := shared.ParseIssueFromArg(args[0])
L38: 			if err != nil {
L39: 				return err
L40: 			}
L41: 			// If the args provided the base repo then use that directly.
L42: 			if baseRepo, present := baseRepo.Value(); present {
L43: 				opts.BaseRepo = func() (ghrepo.Interface, error) {
L44: 					return baseRepo, nil
L45: 				}
L46: 			} else {
L47: 				// support `-R, --repo` override
L48: 				opts.BaseRepo = f.BaseRepo
L49: 			}
L50: 
L51: 			opts.IssueNumber = issueNumber
L52: 
L53: 			if runF != nil {
L54: 				return runF(opts)
L55: 			}
L56: 			return reopenRun(opts)
L57: 		},
L58: 	}
L59: 
L60: 	cmd.Flags().StringVarP(&amp;opts.Comment, &quot;comment&quot;, &quot;c&quot;, &quot;&quot;, &quot;Add a reopening comment&quot;)
L61: 
L62: 	return cmd
L63: }
L64: func reopenRun(opts *ReopenOptions) error {
L65: 	cs := opts.IO.ColorScheme()
L66: 
L67: 	httpClient, err := opts.HttpClient()
L68: 	if err != nil {
L69: 		return err
L70: 	}
L71: 
L72: 	baseRepo, err := opts.BaseRepo()
L73: 	if err != nil {
L74: 		return err
L75: 	}
L76: 
L77: 	issue, err := shared.FindIssueOrPR(httpClient, baseRepo, opts.IssueNumber, []string{&quot;id&quot;, &quot;number&quot;, &quot;title&quot;, &quot;state&quot;})
L78: 	if err != nil {
L79: 		return err
L80: 	}
L81: 	if issue.State == &quot;OPEN&quot; {
L82: 		fmt.Fprintf(opts.IO.ErrOut, &quot;%s Issue %s#%d (%s) is already open\n&quot;, cs.Yellow(&quot;!&quot;), ghrepo.FullName(baseRepo), issue.Number, issue.Title)
L83: 		return nil
L84: 	}
L85: 	if opts.Comment != &quot;&quot; {
L86: 		commentOpts := &amp;prShared.CommentableOptions{
L87: 			Body:       opts.Comment,
L88: 			HttpClient: opts.HttpClient,
L89: 			InputType:  prShared.InputTypeInline,
L90: 			Quiet:      true,
L91: 			RetrieveCommentable: func() (prShared.Commentable, ghrepo.Interface, error) {
L92: 				return issue, baseRepo, nil
L93: 			},
L94: 		}
L95: 		err := prShared.CommentableRun(commentOpts)
L96: 		if err != nil {
L97: 			return err
L98: 		}
L99: 	}
L100: 
L101: 	err = apiReopen(httpClient, baseRepo, issue)
L102: 	if err != nil {
L103: 		return err
L104: 	}
L105: 	fmt.Fprintf(opts.IO.ErrOut, &quot;%s Reopened issue %s#%d (%s)\n&quot;, cs.SuccessIconWithColor(cs.Green), ghrepo.FullName(baseRepo), issue.Number, issue.Title)
L106: 
L107: 	return nil
L108: }
L109: 
L110: func apiReopen(httpClient *http.Client, repo ghrepo.Interface, issue *api.Issue) error {
L111: 	if issue.IsPullRequest() {
L112: 		return api.PullRequestReopen(httpClient, repo, issue.ID)
L113: 	}
L114: 
L115: 	var mutation struct {
L116: 		ReopenIssue struct {
L117: 			Issue struct {
L118: 				ID githubv4.ID
L119: 			}
L120: 		} `graphql:&quot;reopenIssue(input: $input)&quot;`
L121: 	}
L122: 	variables := map[string]any{
L123: 		&quot;input&quot;: githubv4.ReopenIssueInput{
L124: 			IssueID: issue.ID,
L125: 		},
L126: 	}
L127: 
L128: 	gql := api.NewClientFromHTTP(httpClient)
L129: 	return gql.Mutate(repo.RepoHost(), &quot;IssueReopen&quot;, &amp;mutation, variables)
L130: }
</excerpt>
</source>
<source kind="search">
<title>Allow `gh issue close --reason` to change the reason on an already-closed issue · Issue #14364 · cli/cli · GitHub</title>
<location>GitHub issue 14364 in cli/cli (link omitted to avoid creating a cross-reference)</location>
<excerpt>citeturn0search0 [wordlim: 200] Published: last month; Crawled: last month; `gh issue close --reason` returns early on an issue that is already closed, so there is no way to correct a close reason from the CLI. The web UI offers the close-reason control on a closed issue and the REST API accepts `state_reason` on a `PATCH`, so the CLI is the only one of the three that cannot do it.

# Allow `gh issue close --reason` to change the reason on an already-closed issue #14364

New issue

Copy link

New issue

Copy link

Open

Open

Allow `gh issue close --reason` to change the reason on an already-closed issue#14364

Copy link

Labels

needs-triageneeds to be reviewedneeds to be reviewed

## Description

clue

opened on Sep 6, 2026

Issue body actions

### Describe the feature or problem you&#39;d like to solve

`gh issue close --reason` returns early on an issue that is already closed, so there is no way to correct a close reason from the CLI. The web UI offers the close-reason control on a closed issue and the REST API accepts `state_reason` on a `PATCH`, so the CLI is the only one of the three that cannot do it.

The reason is wrong more often than it sounds. A reporter closes their own issue as `completed` when nothing was completed, or a linked commit closes one that turns out to be invalid. Reopening and re-closing works but writes two extra events into the timeline for what is a metadata fix.
    
    $ gh issue view 217 --repo graphp/graph --json state,stateReason
    {&quot;state&quot;:&quot;CLOSED&quot;,&quot;stateReason&quot;:&quot;NOT_PLANNED&quot;}
    
    $ gh issue close 217 --repo graphp/graph --reason completed
    ! Issue graphp/graph#217 (water energy) is already closed
    $ echo $?
    0
    
    $ gh issue view 217 --repo graphp/graph --json state,stateReason
    {&quot;state&quot;:&quot;CLOSED&quot;,&quot;stateReason&quot;:&quot;NOT_PLANNED&quot;}

`gh version 2.100.0 (2026-09-03)`

### Proposed solution

Apply `--reason` when the issue is already closed, instead of returning early in `pkg/cmd/issue/close/close.go`. There is nothing to work around: the close reason is independently mutable on a closed issue, in the web UI and over the API alike.
    
    $ gh api --method PATCH repos/graphp/graph/issues/217 \
        -f state=closed -f state_reason=completed \
        --jq &#39;&quot;\(.state) (\(.state_reason))&quot;&#39;
    closed (completed)
    
    $ gh api --method PATCH repos/graphp/graph/issues/217 \
        -f state=closed -f state_reason=not_planned \
        --jq &#39;&quot;\(.state) (\(.state_reason))&quot;&#39;
    closed (not_planned)

`state=closed` is required alongside `state_reason`. Sent alone the field is ignored and the `PATCH` still returns 2xx, so it looks like it worked.

The same early return also blocks `--duplicate-of`. Scripts and agents currently have to reach for the API or drive the web UI for a change the CLI already models.

### Additional context

Related to #14152, which reports `--comment` being dropped on that same early return, though I do not think this one is a duplicate of it. That issue asks for the comment not to be silently discarded and lists three acceptable fixes: post it anyway, exit non-zero, or warn. Two of the three would leave the reason still unchangeable, and both PRs opened against it, #14160 and #14292, are scoped to `--comment`.

Reactions are currently unavailable
</excerpt>
</source>
<source kind="search">
<title>How can i close all issues set as done in my projects using the gh cli · cli cli · Discussion #6414 · GitHub</title>
<location>GitHub discussion 6414 in cli/cli (link omitted to avoid creating a cross-reference)</location>
<excerpt>citeturn0search1 [wordlim: 200] Published: 4.1 years ago; Crawled: 2 months ago;     gh api graphql --paginate --field projectNumber=2 --raw-field user=LangLangBart --raw-field query=$Query_2 --jq &#39;.[].user.projectV2.items.nodes[] | select(.fieldValueByName.name == &quot;Done&quot;) | select(.type == &quot;ISSUE&quot;) | select(.content.state == &quot;OPEN&quot;) | .content&#39; ...     gh issue list --json number --jq &#39;.[].number&#39; -L 100 | while read number; do gh issue close $number; done
### --jq
    
    gh api graphql --paginate --field projectNumber=2 --raw-field user=LangLangBart --raw-field query=$Query_2 --jq &#39;.[].user.projectV2.items.nodes[] | select(.fieldValueByName.name == &quot;Done&quot;) | select(.type == &quot;ISSUE&quot;) | select(.content.state == &quot;OPEN&quot;) | .content&#39;
    
    # result
    {&quot;number&quot;:2,&quot;repository&quot;:{&quot;nameWithOwner&quot;:&quot;LangLangBart/gh-look&quot;},&quot;state&quot;:&quot;OPEN&quot;}

### --template
    
    gh api graphql --paginate --field projectNumber=2 --raw-field user=LangLangBart --raw-field query=$Query_2 --template &#39;{{- range .data.user.projectV2.items.nodes -}}{{- if .fieldValueByName -}}{{- if (and (eq .type &quot;ISSUE&quot;) (eq .fieldValueByName.name &quot;Done&quot;) (eq .content.state &quot;OPEN&quot;)) }}{{- tablerow (printf &quot;%0.f&quot; .content.number | color &quot;green+h&quot;) .content.repository.nameWithOwner (printf &quot;%s added by %s %s&quot; (.fieldValueByName.name | color &quot;22+b:2&quot;) (.fieldValueByName.creator.login | color &quot;cyan+h&quot;) (timeago .fieldValueByName.updatedAt | color &quot;gray+h&quot;)) -}}{{- tablerender -}}{{- end -}}{{- end -}}{{- end -}}&#39;
              type
              ... on ProjectV2Item {
                fieldValueByName(name: &quot;Status&quot;) {
                  ... on ProjectV2ItemFieldSingleSelectValue {
                    name
                    id
                    creator {
                      login
                    }
                    updatedAt
                  }
                }
              }
              content {
                ... on Issue {
                  id
                  state
                  number
                  repository {
                    nameWithOwner
                  }
                }
              }
            }
          }
        }
      }
    }&#39; \
        --template &#39;{{- range .data.organization.projectV2.items.nodes -}}{{- if .fieldValueByName -}}{{- if (and (eq .type &quot;ISSUE&quot;) (eq .fieldValueByName.name &quot;Done&quot;) (eq .content.state &quot;OPEN&quot;)) }}{{- tablerow (printf &quot;%0.f&quot; .content.number) .content.id .content.repository.nameWithOwner (printf &quot;%s added by %s %s&quot; (.fieldValueByName.name ) (.fieldValueByName.creator.login) (timeago .fieldValueByName.updatedAt)) -}}{{- end -}}{{- end -}}{{- end -}}&#39; \
        ) \
         &amp;&amp; 
    for line in &quot;${lines[@]}&quot;; do {
      issue_id=$(echo &quot;${line}&quot; | awk &#39;{ print $2;}&#39; )
      #echo issue:&quot;${issue_id}&quot;
      
      gh api graphql -f issueId=$issue_id \
        -f query=&#39;
    mutation($issueId:ID!) {
      updateIssue(input: {id : $issueId, state: CLOSED}){
        issue {
          id
          title
        }
      }
    }
    &#39; \
        --jq &#39;{ id: .data.updateIssue.issue.id, title: .data.updateIssue.issue.title }&#39;

All reactions

bohjak May 1, 2024

A crude but simple one-liner to close a 100 issues:
    
    gh issue list --json number --jq &#39;.[].number&#39; -L 100 | while read number; do gh issue close $number; done

You must be logged in to vote

All reactions

5 replies

Comment options

</excerpt>
</source>
<source kind="search">
<title>GitHub - cli/cli: GitHub’s official command line tool · GitHub</title>
<location>https://github.com/cli/cli</location>
<excerpt>citeturn0search2 [wordlim: 200] Crawled: 2 days ago; GitHub CLI&#39;s PGP signing key rotation for Linux package repositories is effective September 5, 2026; users experiencing package installation or update problems can find solutions in the public announcement.

# GitHub CLI

GitHub CLI, or the gh CLI, is GitHub on the command line. It brings pull requests, issues, and other GitHub concepts to the terminal next to where you are already working with `git` and your code.

Important

GitHub CLI&#39;s PGP signing key rotation for Linux package repositories is effective September 5, 2026; users experiencing package installation or update problems can find solutions in the public announcement.

GitHub CLI is supported for users on GitHub.com, GitHub Enterprise Cloud, and supported GitHub Enterprise Server versions, with support for macOS, Windows, and Linux.

## Documentation

For installation options see below, for usage instructions see the manual.

## Agent skills

An agent skill is available for driving `gh` from coding agents. Install or update it with the built-in `gh skill` command:
    
    # Install the skill (user scope recommended)
    gh skill install cli/cli gh --scope user
    
    # Update the skill after a `gh` release
    gh skill update gh

## Contributing

If anything feels off or if you feel that some functionality is missing, please check out the contributing page. There you will find instructions for sharing your feedback, building the tool locally, and submitting pull requests to the project.

## Installation

### macOS

  * Homebrew
  * Precompiled binaries on releases page

For additional macOS packages and installers, see community-supported docs

### Linux &amp; Unix

  * Debian, Raspberry Pi, Ubuntu
  * Amazon Linux, CentOS, Fedora, openSUSE, RHEL, SUSE
  * Precompiled binaries on releases page

For additional Linux &amp; Unix packages and installers, see community-supported docs

### Windows

  * WinGet
  * Precompiled binaries on releases page

For additional Windows packages and installers, see community-supported docs
</excerpt>
</source>
<omitted_sources count="9">Additional source records were omitted from this bounded result.</omitted_sources>
</source_evidence>

Citations:

- 1: https://raw.githubusercontent.com/cli/cli/trunk/pkg/cmd/issue/close/close.go
- 2: https://raw.githubusercontent.com/cli/cli/trunk/pkg/cmd/issue/reopen/reopen.go
- 3: https://raw.githubusercontent.com/cli/cli/trunk/pkg/cmd/issue/close/close.go
- 4: GitHub issue 14364 in cli/cli (link omitted to avoid creating a cross-reference)

Script executed:

set -o pipefail
rg -n -C 30 --glob '*.ts' -e 'registerGhRateLimitResetProbe' -e 'rate_limit' -e 'resetAt' -e 'remaining' src/main/git src/main/github | sed -n '1,1800p'
printf '%s\n' '--- exact gh execution preflight and failure path ---'
nl -ba src/main/git/command-runner/gh-exec-file.ts | sed -n '1,280p'
printf '%s\n' '--- rate-limit probe implementation candidates ---'
rg -l --glob '*.ts' 'registerGhRateLimitResetProbe|resources.*graphql|rate_limit' src/main | sort

Repository: stablyai/orca

Length of output: 42291


Make pr edit classification host-aware.

On GHES, gh pr edit --add-reviewer and --remove-reviewer use REST, but this classifier assigns every pr edit call to graphql. When the GHES core quota is exhausted, Orca records a GraphQL block, invokes the GraphQL reset probe, and leaves REST calls unblocked. A failed probe leaves the five-minute GraphQL fallback in place. Subsequent reviewer calls can return a misleading GraphQL block, and unrelated GraphQL calls can be suppressed.

Use the effective GitHub host when classifying pr edit: select core on GHES and graphql on GitHub.com. This is one shared classifier fix for both reviewer callers. Project-view gh issue close and gh issue reopen use GraphQL and do not need a separate change.

@nwparker
nwparker merged commit 4dca163 into stablyai:main Oct 28, 2026
37 checks passed
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.

[Bug]: The gh rate-limit breaker misses GraphQL exhaustion, so gh pr and issue commands keep failing

2 participants