{"record":{"id":"6fb039127287e6f2","repo":"stablyai/orca","slug":"a-fetch-implementation-is-required","errorCode":null,"errorMessage":"A fetch implementation is required.","messagePattern":"A fetch implementation is required\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"config/scripts/run-release-mac-build-workflow.mjs","lineNumber":144,"sourceCode":"    if (run.status === 'completed') {\n      return run\n    }\n\n    console.log(\n      `Mac release build workflow is ${run.status}; polling again in ${options.pollSeconds}s`\n    )\n    await sleep(options.pollSeconds * 1000)\n  }\n\n  throw new Error(\n    `Timed out after ${options.timeoutMinutes}m waiting for mac release build workflow ${workflowRunId}.`\n  )\n}\n\nexport function createGitHubApiClient(options, deps = {}) {\n  const fetchImpl = deps.fetch ?? globalThis.fetch\n  if (typeof fetchImpl !== 'function') {\n    throw new Error('A fetch implementation is required.')\n  }\n\n  const [owner, repo] = options.repo.split('/')\n  if (!owner || !repo) {\n    throw new Error(`GITHUB_REPOSITORY must be in owner/repo form, got \"${options.repo}\".`)\n  }\n\n  return {\n    owner,\n    repo,\n    async request(method, path, body) {\n      const response = await fetchImpl(`${options.apiBaseUrl}${path}`, {\n        body: body == null ? undefined : JSON.stringify(body),\n        headers: {\n          Accept: 'application/vnd.github+json',\n          Authorization: `Bearer ${options.token}`,\n          'Content-Type': 'application/json',\n          'X-GitHub-Api-Version': DEFAULT_API_VERSION","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/config/scripts/run-release-mac-build-workflow.mjs#L126-L162","documentation":"Thrown by createGitHubApiClient when no fetch implementation is available: deps.fetch is not provided AND globalThis.fetch is not a function. The client needs fetch to call the GitHub API, so it refuses to construct without one.","triggerScenarios":"Running on a Node runtime older than 18 (no global fetch), or in a host that undefined globalThis.fetch, while calling createGitHubApiClient without passing deps.fetch.","commonSituations":"Node 16 EOL runtime, a sandbox that strips fetch, tests that don't inject a fetch double, running the module under an older embedded JS engine.","solutions":["Run on Node 18+ where globalThis.fetch is built in.","Pass a fetch implementation via deps: createGitHubApiClient(options, { fetch: undici.fetch }) (or node-fetch).","In tests, inject a mock fetch through the deps parameter."],"exampleFix":"// before\nconst api = createGitHubApiClient(options)\n// after\nimport { fetch } from 'undici'\nconst api = createGitHubApiClient(options, { fetch })","handlingStrategy":"validation","validationCode":"const fetchImpl = deps.fetch ?? globalThis.fetch\nif (typeof fetchImpl !== 'function') {\n  throw new Error('Provide a fetch impl: createGitHubApiClient(options, { fetch: undici.fetch })')\n}","typeGuard":"function isFetch(value) { return typeof value === 'function' }","tryCatchPattern":"try {\n  api = createGitHubApiClient(options)\n} catch (err) {\n  if (/fetch implementation is required/.test(err.message)) {\n    const { fetch } = await import('undici')\n    api = createGitHubApiClient(options, { fetch })\n  } else throw err\n}","preventionTips":["Require Node 18+ in package.json engines so global fetch exists.","Inject a fetch double in tests via the deps.fetch parameter.","Fail fast at startup with a clear message rather than deep in a request."],"tags":["runtime","fetch","node-version","github-api"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}