Repository navigation
feat: fall back to REST where gh has no GraphQL - #15
Conversation
|
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
88cf053 to
bd98d87
Compare
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>
|
I pushed e209106 with fixes. The fallbacks work, but I couldn't check whether a cloud session's
Small things:
Claude Code ran the three scripts with a signed-in I updated the 🤖 Reviewed with assistance from Claude Code |
|
Thanks for studying this. I don't think it will do any harm, but I didn't understand the whole |
Short Summary (TL;DR)
In Claude Code cloud sessions and on self-hosted runners,
ghpasses on onlygh apiREST requests, so the skills' GraphQL queries and thegh pr,gh issueandgh repocommands fail there. The scripts now fall back to REST, and a newgithub-rest.mdgives the skills REST forms of the other commands.The Issue
/ddev:review,/ddev:commitand/ddev:ci-failureneed a signed-ingh. A Claude Code session on Anthropic's cloud or on a self-hosted runner has aghshim instead, which answers every GraphQL request, and everyghcommand built on GraphQL, with:That breaks
pr-context.sh,mentions.sh, the Buildkite history infailed-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 viewandgh issue create, and the two GraphQL steps that add to an existing pending review.How This PR Solves The Issue
review/pr-context.shccr/review_threadsroute where it exists.review/mentions.shwillCloseTarget, socloses-itisn't shown.ci-failure/failed-job.shreview/github-rest.mdgh pr,gh issueandgh repocommands the skills use, and how to handle an existing pending review, which REST can't add comments to.SKILL.mdfilesgh api 'repos/{owner}/{repo}', which works with both kinds ofgh, and each skill points togithub-rest.mdwhen GraphQL isn't available.README.mdThe GraphQL paths are unchanged, so a signed-in
ghbehaves as before.Manual Testing Instructions
In a Claude Code cloud or self-hosted session with
ddev/ddevattached:Each prints
gh api graphql failed ... reading through RESTon stderr and then the usual output. With a signed-inghon your own machine, the same commands print no such line.Automated Testing Overview
claude plugin validate .andshellcheckpass.Claude Code ran the three scripts on a self-hosted runner, where
ghis the REST-only shim:pr-context.sh 9080showed the review thread withresolved=false outdated=falsefrom the ccr route, andpr-context.sh 9075found issue 9074 fromfixes #9074in the body.mentions.shlisted 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.shprinted the Buildkite history formacos-orbstackthrough REST, and its GitHub Actions path, already REST, also worked.ddevin a checkout ofrfay/ddevand nothing inddev/agent-skills.Not tested: the REST steps for pending reviews in
github-rest.md, and the scripts' GraphQL paths with a signed-inghafter 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