Repository navigation
ref(github): Share one GitHub API helper across tools - #2692
Merged
Merged
Conversation
Every GitHub tool built its own Request with the same headers, then parsed the body and formatted errors with its own copy of readJson, githubError, and parseRepo. Move that into githubApi, githubErrorMessage, parseRepo, and repoPath in tool-support/github-api.ts. Requests still go only through host egress with the same operation names, and each tool keeps its own status-to-error mapping. Error text now includes REST validation details and GraphQL messages for every tool, not only the ones that had that parsing. Co-Authored-By: BYK <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
BYK
requested changes
Nov 4, 2026
BYK
left a comment
Member
There was a problem hiding this comment.
Also enforce using this through a lint rule (prefer oxlint over ast-grep)
Add the junior/use-github-api oxlint rule. It flags egress.fetch calls in junior-github src, except in tool-support/github-api.ts, so new tools use the shared helper.
Contributor
|
1 screenshot change — 1 changed · 0 added · 0 removed Review screenshots in Frameshift
|
BYK
enabled stacked auto-merge (squash)
November 5, 2026 10:00
BYK
approved these changes
Nov 5, 2026
BYK
pushed a commit
that referenced
this pull request
Nov 5, 2026
…2693) Follow-up to #2690, from [Bugbot's review comment](#2690 (comment)). `POST /pulls/{n}/comments/{id}/replies` accepts only the first comment of a thread. GitHub's docs say: "Replies to replies are not supported." Events often name a later reply, so `github_commentOnPullRequest` failed with 404 or 422 in the usual case. Now, when `in_reply_to` is set, the tool reads the comment (`github.pull.comment.get`) and replies to its `in_reply_to_id` when it has one. A missing comment returns a `PluginToolInputError`. This PR is stacked on #2692, which changes the same file. <!-- junior-session-footer:start --> <!-- junior-conversation-id:local%3Aweb%3A3ee1f99a8027cbdb43eb2584 --> -- [View Session in Sentry](https://sentry.sentry.io/explore/conversations/local%3Aweb%3A3ee1f99a8027cbdb43eb2584/?project=4510944073809921) <!-- junior-session-footer:end --> --------- Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
This branch was successfully deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Every GitHub tool built its own
Requestwith the same headers. Each one also had its own copy ofreadJson,githubError/githubApiErrorMessage, andparseRepo. This PR moves that code intosrc/tool-support/github-api.ts:githubApi(egress, { operation, path, method?, body?, apiVersion?, signal? })sends the request through host egress and returns{ ok, status, body }. The body is parsed as JSON, or kept as text when it is not JSON.githubErrorMessage(body)reads REST errors asmessage: resource=… field=… code=…and GraphQL errors as the joinederrors[].message.parseRepoandrepoPathreplace the per-file copies.All tools, the conversation-title lookup in
plugin.ts, and the Stacks client now use it.Lint rule: the new oxlint rule
junior/use-github-api(intools/oxlint/junior) flagsegress.fetchcalls injunior-github/src. It is off only intool-support/github-api.ts. The existinggithubRequestandfetchrestriction messages now namegithubApi.What stays the same
operationnames are unchanged.PluginToolInputErrorvs.Error), because the status that means bad input differs per route.Errorthrows.What changes
AcceptandX-GitHub-Api-Version.Not in scope: the webhook paths in
webhooks/check-suite.tsandwebhooks/installation-requests.tscallgithubRequestincredential-support.tswith an App installation token, not egress. That is a different auth path, so it stays as it is.Follow-up to the Octokit discussion: we did not add
octokit, because egress owns credentials andoperationselects the grant.--
View Session in Sentry