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
{{ message }}
Repository navigation
fix(github): count gh pr and issue commands against the GraphQL rate limit - #28778
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:
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.
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.
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)
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: 4 · 1
Failed checks: 1 warning
Check name
Status
Explanation
Resolution
Docstring Coverage
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 checks: 4 passed
Check name
Status
Explanation
Title check
The title clearly and concisely describes the main change: counting gh pr and gh issue commands against the GraphQL rate limit.
Description check
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
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
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.
…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.
Fixesstablyai#28767
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.
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.
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>citeturn1view2 [wordlim: 200] Crawled: today; Content type: text/plain; Source: open({"ref_id":"https://raw.githubusercontent.com/cli/cli/trunk/pkg/cmd/issue/close/close.go","lineno":null}); Total lines: 201
L0: package close
L1:
L2: import (
L3: "fmt"
L4: "net/http"
L5:
L6: "github.com/MakeNowJust/heredoc"
L7: "github.com/cli/cli/v2/api"
L8: "github.com/cli/cli/v2/internal/ghrepo"
L9: "github.com/cli/cli/v2/pkg/cmd/issue/shared"
L10: prShared "github.com/cli/cli/v2/pkg/cmd/pr/shared"
L11: "github.com/cli/cli/v2/pkg/cmdutil"
L12: "github.com/cli/cli/v2/pkg/iostreams"
L13: "github.com/shurcooL/githubv4"
L14: "github.com/spf13/cobra"
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 := &CloseOptions{
L29: IO: f.IOStreams,
L30: HttpClient: f.HttpClient,
L31: }
L32: cmd := &cobra.Command{
L33: Use: "close {<number> | <url>}",
L34: Short: "Close issue",
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 "Closing this issue"
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 "not planned"
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 != "" {
L64: if opts.Reason == "" {
L65: opts.Reason = "duplicate"
L66: } else if opts.Reason != "duplicate" {
L67: return cmdutil.FlagErrorf("`--duplicate-of` can only be used with `--reason duplicate`")
L68: }
L69: }
L70:
L71: if runF != nil {
L72: return runF(opts)
L73: }
L74: return closeRun(opts)
L75: },
L76: }
L77: cmd.Flags().StringVarP(&opts.Comment, "comment", "c", "", "Leave a closing comment")
L78: cmdutil.StringEnumFlag(cmd, &opts.Reason, "reason", "r", "", []string{"completed", "not planned", "duplicate"}, "Reason for closing")
L79: cmd.Flags().StringVar(&opts.DuplicateOf, "duplicate-of", "", "Mark as duplicate of another issue by number or URL")
L80:
L81: return cmd
L82: }
L83: func closeRun(opts *CloseOptions) error {
L84: cs := opts.IO.ColorScheme()
L85: closeReason := opts.Reason
L86: if opts.DuplicateOf != "" {
L87: if closeReason == "" {
L88: closeReason = "duplicate"
L89: } else if closeReason != "duplicate" {
L90: return cmdutil.FlagErrorf("`--duplicate-of` can only be used with `--reason duplicate`")
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{"id", "number", "title", "state"})
L104: if err != nil {
L105: return err
L106: }
L107:
L108: if issue.State == "CLOSED" {
L109: fmt.Fprintf(opts.IO.ErrOut, "%s Issue %s#%d (%s) is already closed\n", cs.Yellow("!"), ghrepo.FullName(baseRepo), issue.Number, issue.Title)
L110: return nil
L111: }
L112: var duplicateIssueID string
L113: if opts.DuplicateOf != "" {
L114: if issue.IsPullRequest() {
L115: return cmdutil.FlagErrorf("`--duplicate-of` is only supported for issues")
L116: }
L117: duplicateIssueNumber, duplicateRepo, err := shared.ParseIssueFromArg(opts.DuplicateOf)
L118: if err != nil {
L119: return cmdutil.FlagErrorf("invalid value for `--duplicate-of`: %v", err)
L120: }
L121: duplicateIssueRepo := baseRepo
L122: if parsedRepo, present := duplicateRepo.Value(); present {
L123: duplicateIssueRepo = parsedRepo
L124: }
L125: if ghrepo.IsSame(baseRepo, duplicateIssueRepo) && issue.Number == duplicateIssueNumber {
L126: return cmdutil.FlagErrorf("`--duplicate-of` cannot reference the current issue")
L127: }
L128: duplicateIssue, err := shared.FindIssueOrPR(httpClient, duplicateIssueRepo, duplicateIssueNumber, []string{"id"})
L129: if err != nil {
L130: return err
L131: }
L132: if duplicateIssue.IsPullRequest() {
L133: return cmdutil.FlagErrorf("`--duplicate-of` must reference an issue")
L134: }
L135: duplicateIssueID = duplicateIssue.ID
L136: }
L137: if opts.Comment != "" {
L138: commentOpts := &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, "%s Closed issue %s#%d (%s)\n", 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 "":
L168: // If no reason is specified do not set it.
L169: case "not planned":
L170: reason = "NOT_PLANNED"
L171: case "duplicate":
L172: reason = "DUPLICATE"
L173: default:
L174: reason = "COMPLETED"
L175: }
L176:
L177: var mutation struct {
L178: CloseIssue struct {
L179: Issue struct {
L180: ID githubv4.ID
L181: }
L182: } `graphql:"closeIssue(input: $input)"`
L183: }
L184:
L185: variables := map[string]any{
L186: "input": CloseIssueInput{
L187: IssueID: issue.ID,
L188: StateReason: reason,
L189: DuplicateIssueID: duplicateIssueID,
L190: },
L191: }
L192: gql := api.NewClientFromHTTP(httpClient)
L193: return gql.Mutate(repo.RepoHost(), "IssueClose", &mutation, variables)
L194: }
L195:
L196: type CloseIssueInput struct {
L197: IssueID string `json:"issueId"`
L198: StateReason string `json:"stateReason,omitempty"`
L199: DuplicateIssueID string `json:"duplicateIssueId,omitempty"`
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>citeturn1view3 [wordlim: 200] Crawled: last week; Content type: text/plain; Source: open({"ref_id":"https://raw.githubusercontent.com/cli/cli/trunk/pkg/cmd/issue/reopen/reopen.go","lineno":null}); Total lines: 131
L0: package reopen
L1:
L2: import (
L3: "fmt"
L4: "net/http"
L5:
L6: "github.com/cli/cli/v2/api"
L7: "github.com/cli/cli/v2/internal/gh"
L8: "github.com/cli/cli/v2/internal/ghrepo"
L9: "github.com/cli/cli/v2/pkg/cmd/issue/shared"
L10: prShared "github.com/cli/cli/v2/pkg/cmd/pr/shared"
L11: "github.com/cli/cli/v2/pkg/cmdutil"
L12: "github.com/cli/cli/v2/pkg/iostreams"
L13: "github.com/shurcooL/githubv4"
L14: "github.com/spf13/cobra"
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 := &ReopenOptions{
L28: IO: f.IOStreams,
L29: HttpClient: f.HttpClient,
L30: Config: f.Config,
L31: }
L32: cmd := &cobra.Command{
L33: Use: "reopen {<number> | <url>}",
L34: Short: "Reopen issue",
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(&opts.Comment, "comment", "c", "", "Add a reopening comment")
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{"id", "number", "title", "state"})
L78: if err != nil {
L79: return err
L80: }
L81: if issue.State == "OPEN" {
L82: fmt.Fprintf(opts.IO.ErrOut, "%s Issue %s#%d (%s) is already open\n", cs.Yellow("!"), ghrepo.FullName(baseRepo), issue.Number, issue.Title)
L83: return nil
L84: }
L85: if opts.Comment != "" {
L86: commentOpts := &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, "%s Reopened issue %s#%d (%s)\n", 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:"reopenIssue(input: $input)"`
L121: }
L122: variables := map[string]any{
L123: "input": githubv4.ReopenIssueInput{
L124: IssueID: issue.ID,
L125: },
L126: }
L127:
L128: gql := api.NewClientFromHTTP(httpClient)
L129: return gql.Mutate(repo.RepoHost(), "IssueReopen", &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>citeturn0search0 [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'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
{"state":"CLOSED","stateReason":"NOT_PLANNED"}
$ 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
{"state":"CLOSED","stateReason":"NOT_PLANNED"}
`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 '"\(.state) (\(.state_reason))"'
closed (completed)
$ gh api --method PATCH repos/graphp/graph/issues/217 \
-f state=closed -f state_reason=not_planned \
--jq '"\(.state) (\(.state_reason))"'
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>citeturn0search1 [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 '.[].user.projectV2.items.nodes[] | select(.fieldValueByName.name == "Done") | select(.type == "ISSUE") | select(.content.state == "OPEN") | .content' ... gh issue list --json number --jq '.[].number' -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 '.[].user.projectV2.items.nodes[] | select(.fieldValueByName.name == "Done") | select(.type == "ISSUE") | select(.content.state == "OPEN") | .content'
# result
{"number":2,"repository":{"nameWithOwner":"LangLangBart/gh-look"},"state":"OPEN"}
### --template
gh api graphql --paginate --field projectNumber=2 --raw-field user=LangLangBart --raw-field query=$Query_2 --template '{{- range .data.user.projectV2.items.nodes -}}{{- if .fieldValueByName -}}{{- if (and (eq .type "ISSUE") (eq .fieldValueByName.name "Done") (eq .content.state "OPEN")) }}{{- tablerow (printf "%0.f" .content.number | color "green+h") .content.repository.nameWithOwner (printf "%s added by %s %s" (.fieldValueByName.name | color "22+b:2") (.fieldValueByName.creator.login | color "cyan+h") (timeago .fieldValueByName.updatedAt | color "gray+h")) -}}{{- tablerender -}}{{- end -}}{{- end -}}{{- end -}}'
type
... on ProjectV2Item {
fieldValueByName(name: "Status") {
... on ProjectV2ItemFieldSingleSelectValue {
name
id
creator {
login
}
updatedAt
}
}
}
content {
... on Issue {
id
state
number
repository {
nameWithOwner
}
}
}
}
}
}
}
}' \
--template '{{- range .data.organization.projectV2.items.nodes -}}{{- if .fieldValueByName -}}{{- if (and (eq .type "ISSUE") (eq .fieldValueByName.name "Done") (eq .content.state "OPEN")) }}{{- tablerow (printf "%0.f" .content.number) .content.id .content.repository.nameWithOwner (printf "%s added by %s %s" (.fieldValueByName.name ) (.fieldValueByName.creator.login) (timeago .fieldValueByName.updatedAt)) -}}{{- end -}}{{- end -}}{{- end -}}' \
) \
&&
for line in "${lines[@]}"; do {
issue_id=$(echo "${line}" | awk '{ print $2;}' )
#echo issue:"${issue_id}"
gh api graphql -f issueId=$issue_id \
-f query='
mutation($issueId:ID!) {
updateIssue(input: {id : $issueId, state: CLOSED}){
issue {
id
title
}
}
}
' \
--jq '{ id: .data.updateIssue.issue.id, title: .data.updateIssue.issue.title }'
All reactions
bohjak May 1, 2024
A crude but simple one-liner to close a 100 issues:
gh issue list --json number --jq '.[].number' -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>citeturn0search2 [wordlim: 200] Crawled: 2 days ago; GitHub CLI'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'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 & Unix
* Debian, Raspberry Pi, Ubuntu
* Amazon Linux, CentOS, Fedora, openSUSE, RHEL, SUSE
* Precompiled binaries on releases page
For additional Linux & 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)
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.
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
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.
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 prandgh issuecommands 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
ghcommand exceptgh apiandgh searchcounted against REST.After: these
ghsubcommands, which Orca runs and which use GraphQL, count against GraphQL:pr checks/close/create/edit/list/merge/ready/reopen/viewissue close/edit/list/reopen/viewrepo viewEverything else, such as
gh run listandgh auth status, stays on REST.Detecting the limit, before: only
API rate limit exceededtripped the breaker.After: GraphQL's
API rate limit already exceededtrips 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 editchanges 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:
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.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
ghcommands 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
mainat 3879c6d):oxlint,oxfmt --check, andtsc(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 statusand a bareprstay on REST. GraphQL's wording counts as a primary limit. The old assertion thatpr listis REST is replaced.src/main/git/runner-gh-rate-limit-breaker.test.ts: apr viewthat fails with the GraphQL message blocks only GraphQL. A followingissue closeis refused without startinggh, and a RESTgh apicall 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 otherghrunner test and test undersrc/main/github.Typecheck and lint:
tsc --noEmit -p config/tsconfig.node.json(whatpnpm tc:noderuns) andoxlintare clean, andoxfmt --checkis 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 typecheckandpnpm 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
Notes
Ensure no issues in: Security, Cross-platoform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)