Repository navigation
refactor(github): build request headers once - #492
Merged
Merged
Conversation
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The small extraction preserves supported request behavior, and no blocking issues remain.
Review effort: Balanced
Findings: None
What changed in this PR
Centralizes request-header construction in GitHubApi without changing supported header values.
Changes:
- Adds a private builder for the accept and API-version headers.
- Uses it for REST requests, pagination, and GraphQL, preserving custom accept values.
| File | Description |
|---|---|
| src/github/api.ts | Replaces three inline header objects with one shared builder. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
GitHubApi built the accept and x-github-api-version pair inline at three request sites (tryList, request, tryGraphql). The pair now rides on Octokit's request defaults, set once after construction; the raw media-type read passes its own accept, which the defaults merge lets override, and the plugins' wrapped hook stays. Nothing on the wire changes.
Vivswan
force-pushed
the
refactor/github-api-headers-once
branch
from
October 6, 2026 10:42
79a27e9 to
680fa50
Compare
Vivswan
marked this pull request as ready for review
October 6, 2026 10:49
Vivswan
enabled auto-merge (squash)
October 6, 2026 20:36
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.
Before
After
How
accept, which the defaults merge lets override.defaults()keeps the wrapped request hook, so retry, throttling, and the request log see every call.Proof
grep -c '"x-github-api-version"' src/github/api.ts, 3 before, 1 after.bun test/e2e/run.ts --sections labels,branches, 98/98; the mock refuses any request without the version header, on the list, request, and GraphQL paths alike.bun run test test/github, 123 pass, none added.Technical details
@octokit/core7.0.8 (already a dependency),request.defaults({ headers }); the constructor takes no header option beyonduserAgentandtimeZone, so the defaults are set right after construction.endpointanddefaults.