Conversation
…tbluefin#1232) The ESM fetch sites already route through lib/gh.js (PRs projectbluefin#1236, projectbluefin#1257). This closes the CJS side of issue projectbluefin#1232 by making lib/request-queue.js the CJS twin of lib/gh.js and migrating the remaining hand-rolled GitHub REST sites onto it. lib/request-queue.js: - Add githubToken() as the single token source (GITHUB_TOKEN then GH_TOKEN). - Extend githubHeaders() to the one header contract — Accept application/vnd.github+json, pinned x-github-api-version 2022-11-28, project user-agent, optional Bearer auth — with per-call overrides for endpoints that need a different representation. - Add githubFetch() mirroring lib/gh.js githubFetch: resolves relative paths against the canonical origin, forwards an optional AbortSignal timeout, and throws on non-2xx unless throwOnError is false (for the fail-soft callers that prefer a fallback payload over an exception). fetch-feeds.js, fetch-pin-state.js: - Drop their inline GITHUB_TOKEN/GH_TOKEN reads, hand-built header objects, and raw fetch() calls; go through githubToken()/githubHeaders()/ githubFetch(). fetch-feeds keeps its Link pagination via the returned Response; fetch-pin-state keeps its v3+json accept override, its user-agent, and its 15s AbortSignal timeout. - fetch-feeds now fails soft through githubFetch({ throwOnError:false }), preserving the Atom-feed fallback on a non-2xx. Behaviour is neutral: same endpoints, same pagination, same timeouts, same fail-soft wrappers — only token acquisition and header/auth construction are deduplicated. GitHub treats application/vnd.github.v3+json and application/vnd.github+json identically. fetch-hive-history.js is intentionally left for a follow-up: its ghHeaders() helper is also used for the non-GitHub hosted Knuckle snapshot endpoint, so it needs a separate pass rather than a mechanical swap. Verified: npm test (1147 tests) passes; eslint clean on all changed files. — hive: backend=goose model=deepseek/deepseek-v4-flash-0731 Signed-off-by: mendezr <mendezr@users.noreply.github.com>
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.
What
Converges the remaining hand-rolled CJS GitHub REST fetchers onto a single shared client, closing the CJS half of architect issue #1232. The ESM half already routes through
scripts/lib/gh.js(PRs #1236 and #1257).scripts/lib/gh.jsbecame the single ESM GitHub client; this PR makesscripts/lib/request-queue.jsits CJS twin and migrates the hand-rolled CJS sites onto it.scripts/lib/request-queue.js:githubToken()— the one token source (GITHUB_TOKEN, thenGH_TOKEN).githubHeaders(token, opts)— the one header contract:Accept: application/vnd.github+json, pinnedx-github-api-version: 2022-11-28, project user-agent, optionalBearerauth. Callers overrideacceptonly where an endpoint needs a different representation.githubFetch(path, { headers, signal, throwOnError })— one request through the shared client, mirroringlib/gh.jsgithubFetch. Resolves relative paths against the canonical origin, forwards an optionalAbortSignaltimeout, and throws on non-2xx unlessthrowOnError: false.scripts/fetch-feeds.jsandscripts/fetch-pin-state.js:GITHUB_TOKEN/GH_TOKENreads, hand-built header objects, and rawfetch()calls; go throughgithubToken()/githubHeaders()/githubFetch().fetch-feedskeeps its Link pagination (reads the returnedResponse) and its Atom-feed fallback (viathrowOnError: false).fetch-pin-statekeeps itsv3+jsonaccept override, its user-agent, and its 15sAbortSignaltimeout.Behaviour
Neutral. Same endpoints, same pagination, same timeouts, same fail-soft wrappers — only the token acquisition and header/auth construction are deduplicated. GitHub treats
application/vnd.github.v3+jsonandapplication/vnd.github+jsonidentically, so the header convergence changes no returned data.Verified:
npm test(1147 tests) passes;eslintclean on all changed files.Left for later
fetch-hive-history.jsis intentionally not migrated in this pass: itsghHeaders()helper is also used for the non-GitHub hosted Knuckle snapshot endpoint, so it warrants a dedicated follow-up rather than a mechanical swap.— hive: backend=goose model=deepseek/deepseek-v4-flash-0731