Skip to content

Authorize gh api endpoints written with a leading slash - #69

Draft
josephschorr wants to merge 1 commit into
mainfrom
gh-api-leading-slash
Draft

josephschorr wants to merge 1 commit into
mainfrom
gh-api-leading-slash

Conversation

@josephschorr

Copy link
Copy Markdown
Member

Motivation

An agent that needed to fork a repository ran gh api -X POST /repos/OWNER/NAME/forks. The call was refused outright, twice, with no approval prompt a person could answer. The same call without the leading slash raised an approval and went through. gh accepts both spellings, and GitHub's REST documentation prints endpoints with the slash, so the refused form is the one an agent is most likely to write.

Summary of changes

  • gh api endpoints written with a leading slash now resolve to the same repository as the bare form, for both reads and writes. gh api /user and slashed search endpoints are recognized the same way.
  • An endpoint that names no repository still fails closed, as does one with more than one leading slash.

Alternatives considered

  • Improving the retry hint only. The hint already told the agent which form to use, and it still took three attempts. Accepting the spelling gh itself accepts removes the failure rather than explaining it.

Provenance

  • Author: Joseph Schorr
  • Person who read the diff:

Ship gate

  • mage test:unit
  • mage test:integration
  • mage test:e2e

Unit passes. The first integration run had one failure and the first e2e run had three, all in unrelated scenarios and all on a heavily loaded machine. Each of the four passed when re-run on its own. A full re-run of both suites is in progress, and this stays a draft until it is green.

Regeneration

n/a

Coverage

  • This does not add user-visible behavior
  • This touches authorization, and mage test:integration + mage test:e2e are green (pending the re-run above)

gh strips a leading slash from an api endpoint, and GitHub's REST docs
print endpoints that way, but the gh toolkit only recognized the bare
form. A call such as 'gh api -X POST /repos/OWNER/NAME/forks' therefore
named no repository and was refused outright, with no approval a person
could grant. The slashed and bare spellings now resolve to the same
repository; an endpoint that names none still fails closed.
@vercel

vercel Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
openagentprimitives Ignored Ignored Nov 12, 2026 10:30pm UTC

Request Review

This branch has not been deployed

No deployments
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.

1 participant