Skip to content

feat: fall back to REST where gh has no GraphQL - #15

Merged
rfay merged 3 commits into
ddev:mainfrom
rfay:20261114_rfay_gh_rest_fallback
Nov 17, 2026
Merged

rfay merged 3 commits into
ddev:mainfrom
rfay:20261114_rfay_gh_rest_fallback

Conversation

@rfay

@rfay rfay commented Nov 15, 2026 •

Copy link
Copy Markdown
Member

Short Summary (TL;DR)

In Claude Code cloud sessions and on self-hosted runners, gh passes on only gh api REST requests, so the skills' GraphQL queries and the gh pr, gh issue and gh repo commands fail there. The scripts now fall back to REST, and a new github-rest.md gives the skills REST forms of the other commands.

The Issue

/ddev:review, /ddev:commit and /ddev:ci-failure need a signed-in gh. A Claude Code session on Anthropic's cloud or on a self-hosted runner has a gh shim instead, which answers every GraphQL request, and every gh command built on GraphQL, with:

HTTP 403: GitHub GraphQL is not available from Claude Code sessions; use the REST API (gh api repos/{owner}/{repo}/...)

That breaks pr-context.sh, mentions.sh, the Buildkite history in failed-job.sh, the fork check in all three skills (gh repo view --json parent), gh pr view, gh pr create, gh pr edit, gh issue view and gh issue create, and the two GraphQL steps that add to an existing pending review.

How This PR Solves The Issue

File Change
review/pr-context.sh When the GraphQL request fails, reads the same sections through REST. Closing issues come from closing keywords in the body, and thread resolution from Claude Code's ccr/review_threads route where it exists.
review/mentions.sh Falls back to the REST issue timeline. REST has no willCloseTarget, so closes-it isn't shown.
ci-failure/failed-job.sh The Buildkite history falls back to one REST statuses request per commit. The shim prints its error to stdout, so the GraphQL output is printed only on success.
review/github-rest.md New. REST forms of the gh pr, gh issue and gh repo commands the skills use, and how to handle an existing pending review, which REST can't add comments to.
All three SKILL.md files The fork check uses gh api 'repos/{owner}/{repo}', which works with both kinds of gh, and each skill points to github-rest.md when GraphQL isn't available.
README.md A note says how the skills behave in cloud and self-hosted sessions, that the REST fallback needs jq, and that those sessions get plugins from the claude.ai account or organization, not from a local install.

The GraphQL paths are unchanged, so a signed-in gh behaves as before.

Manual Testing Instructions

In a Claude Code cloud or self-hosted session with ddev/ddev attached:

plugins/ddev/skills/review/pr-context.sh 9080 ddev/ddev
plugins/ddev/skills/review/mentions.sh 9074 ddev/ddev
plugins/ddev/skills/ci-failure/failed-job.sh https://buildkite.com/ddev/macos-orbstack/builds/8863

Each prints gh api graphql failed ... reading through REST on stderr and then the usual output. With a signed-in gh on your own machine, the same commands print no such line.

Automated Testing Overview

claude plugin validate . and shellcheck pass.

Claude Code ran the three scripts on a self-hosted runner, where gh is the REST-only shim:

  • pr-context.sh 9080 showed the review thread with resolved=false outdated=false from the ccr route, and pr-context.sh 9075 found issue 9074 from fixes #9074 in the body.
  • mentions.sh listed the PRs that mention fix(nginx): anchor TYPO3 deny rule for vendor, typo3_src and typo3temp/var ddev#9127 and #9074, with 9075 as merged.
  • failed-job.sh printed the Buildkite history for macos-orbstack through REST, and its GitHub Actions path, already REST, also worked.
  • The fork check printed ddev in a checkout of rfay/ddev and nothing in ddev/agent-skills.

Not tested: the REST steps for pending reviews in github-rest.md, and the scripts' GraphQL paths with a signed-in gh after this change.

Release/Deployment Notes

The REST fallbacks need jq.

This is a draft while we finish working out how DDEV maintainers use Claude Code cloud and self-hosted sessions. A self-hosted session on Claude Code 2.1.325 got the claude.ai organization's plugins and skills, and none from the runner. Nobody has yet added this plugin to the claude.ai plugin catalog and used it in such a session.

https://claude.ai/code/session_01T3Cc2JVFh9zuVsana1ehR6


Generated by Claude Code

@rfay

rfay commented Nov 16, 2026

Copy link
Copy Markdown
Member Author

I'm not at all sure this is valid; gh may work with claude proxying it.

In Claude Code cloud sessions and on self-hosted runners, `gh` passes on only `gh api` REST requests, so the skills' GraphQL queries and the `gh pr`, `gh issue` and `gh repo` commands fail there. The scripts now fall back to REST, and a new `github-rest.md` gives the skills REST forms of the other commands.

`/ddev:review`, `/ddev:commit` and `/ddev:ci-failure` need a signed-in `gh`. A Claude Code session on Anthropic's cloud or on a self-hosted runner has a `gh` shim instead, which answers every GraphQL request, and every `gh` command built on GraphQL, with:

```
HTTP 403: GitHub GraphQL is not available from Claude Code sessions; use the REST API (gh api repos/{owner}/{repo}/...)
```

That breaks `pr-context.sh`, `mentions.sh`, the Buildkite history in `failed-job.sh`, the fork check in all three skills (`gh repo view --json parent`), `gh pr view`, `gh pr create`, `gh pr edit`, `gh issue view` and `gh issue create`, and the two GraphQL steps that add to an existing pending review.

| File | Change |
| --- | --- |
| `review/pr-context.sh` | When the GraphQL request fails, reads the same sections through REST. Closing issues come from closing keywords in the body, and thread resolution from Claude Code's `ccr/review_threads` route where it exists. |
| `review/mentions.sh` | Falls back to the REST issue timeline. REST has no `willCloseTarget`, so `closes-it` isn't shown. |
| `ci-failure/failed-job.sh` | The Buildkite history falls back to one REST statuses request per commit. The shim prints its error to stdout, so the GraphQL output is printed only on success. |
| `review/github-rest.md` | New. REST forms of the `gh pr`, `gh issue` and `gh repo` commands the skills use, and how to handle an existing pending review, which REST can't add comments to. |
| All three `SKILL.md` files | The fork check uses `gh api 'repos/{owner}/{repo}'`, which works with both kinds of `gh`, and each skill points to `github-rest.md` when GraphQL isn't available. |
| `README.md` | The requirements mention the cloud and self-hosted `gh`, and a note says how the skills behave in those sessions. |

The GraphQL paths are unchanged, so a signed-in `gh` behaves as before.

In a Claude Code cloud or self-hosted session with `ddev/ddev` attached:

```bash
plugins/ddev/skills/review/pr-context.sh 9080 ddev/ddev
plugins/ddev/skills/review/mentions.sh 9074 ddev/ddev
plugins/ddev/skills/ci-failure/failed-job.sh https://buildkite.com/ddev/macos-orbstack/builds/8863
```

Each prints `gh api graphql failed ... reading through REST` on stderr and then the usual output. With a signed-in `gh` on your own machine, the same commands print no such line.

`claude plugin validate .` and `shellcheck` pass.

Claude Code ran the three scripts on a self-hosted runner, where `gh` is the REST-only shim:

- `pr-context.sh 9080` showed the review thread with `resolved=false outdated=false` from the ccr route, and `pr-context.sh 9075` found issue 9074 from `fixes #9074` in the body.
- `mentions.sh` listed the PRs that mention ddev/ddev#9127 and #9074, with 9075 as merged.
- `failed-job.sh` printed the Buildkite history for `macos-orbstack` through REST, and its GitHub Actions path, already REST, also worked.
- The fork check printed `ddev` in a checkout of `rfay/ddev` and nothing in `ddev/agent-skills`.

Not tested: the REST steps for pending reviews in `github-rest.md`, and the scripts' GraphQL paths with a signed-in `gh` after this change.

The REST fallbacks need `jq`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T3Cc2JVFh9zuVsana1ehR6
Sessions get the plugins and skills of the claude.ai account and
organization, not those installed locally. Drop the untested claim
about the runner's host config directory.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T3Cc2JVFh9zuVsana1ehR6
@stasadev
stasadev force-pushed the 20261114_rfay_gh_rest_fallback branch from 88cf053 to bd98d87 Compare November 17, 2026 12:43
The REST fallbacks hid the GraphQL error with `2> /dev/null`, so a signed-in `gh` that hit a rate limit or a network error switched to REST without saying why. Each script now passes on `gh`'s own error, then prints `(gh api graphql failed; reading through REST)`. `failed-job.sh` didn't print that line before.

`pr-context.sh` stopped with `gh: Not Found (HTTP 404)` when the body had `fixes #N` for a number that isn't an issue in the repository, as PR ddev#15's own body does. It now prints `(skipping #N from the body)` and goes on.

Smaller changes:

- `pr-context.sh` through REST prints `state=MERGED`, `OPEN` or `CLOSED` as the GraphQL path does, and notes unknown thread resolution only when there are review comments.
- `failed-job.sh` drops the `default_branch` request, because the commits list already defaults to that branch.
- The README requirement rows are back as they were; the paragraph about cloud and self-hosted sessions says the fallback needs jq.
- `github-rest.md` shows `--title T` in the `gh issue create` row.

Claude Code ran the three scripts on Linux with a signed-in `gh` and with a stub `gh` first on `PATH`, which fails GraphQL and `gh pr`, `gh issue` and `gh repo` with an HTTP 403 on stderr. The GraphQL output didn't change. The REST output matched it for ddev/ddev#9080 and #9075, `mentions.sh 9074`, and the `macos-orbstack` history. `pr-context.sh 15 ddev/agent-skills` now finishes. `shellcheck` and `claude plugin validate .` pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@stasadev

Copy link
Copy Markdown
Member

I pushed e209106 with fixes. The fallbacks work, but I couldn't check whether a cloud session's gh refuses GraphQL, so your doubt above still needs gh api graphql -f query='{viewer{login}}' run in one.

  1. pr-context.sh stopped with gh: Not Found (HTTP 404) on this very PR through REST. The body has fixes #9074 in backticks, and agent-skills has no issue 9074. It now prints (skipping #9074 from the body) and goes on.
  2. The fallbacks hid the GraphQL error with 2> /dev/null, so a signed-in gh that hit a rate limit or a network error went to REST without saying why. Now gh's own error shows, then (gh api graphql failed; reading through REST), in failed-job.sh too.

Small things:

  • REST output prints state=MERGED/OPEN/CLOSED like GraphQL, and (resolution unknown through REST) only when there are review comments.
  • failed-job.sh doesn't need the default_branch request, because the commits list defaults to that branch.
  • The README requirement rows are back as they were, since they got hard to read. The paragraph below them says the fallback needs jq.

Claude Code ran the three scripts with a signed-in gh and with a stub gh that fails GraphQL with an HTTP 403. The GraphQL output didn't change, and the REST output matched it for ddev/ddev#9080, #9075, mentions.sh 9074 and the macos-orbstack history. The REST steps for pending reviews in github-rest.md weren't tested.

I updated the README.md row in the PR body to match.

🤖 Reviewed with assistance from Claude Code

@rfay
rfay marked this pull request as ready for review November 17, 2026 13:47
@rfay

rfay commented Nov 17, 2026

Copy link
Copy Markdown
Member Author

Thanks for studying this. I don't think it will do any harm, but I didn't understand the whole gh shim thing when I did it, but now I've seen the shim mostly work, but probably doesn't have graphql

@stasadev stasadev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, approving it.

@rfay
rfay merged commit 73f9c31 into ddev:main Nov 17, 2026
1 check 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.

3 participants