{"record":{"id":"22bff7c6f82e4095","repo":"stablyai/orca","slug":"github-api-method-path-failed-with-respons","errorCode":null,"errorMessage":"GitHub API ${method} ${path} failed with ${response.status}: ${formatApiError(data)}","messagePattern":"GitHub API (.+?) (.+?) failed with (.+?): (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"config/scripts/run-release-mac-build-workflow.mjs","lineNumber":170,"sourceCode":"  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\n        },\n        method\n      })\n      const text = await response.text()\n      const data = text.length > 0 ? JSON.parse(text) : null\n\n      if (!response.ok) {\n        throw new Error(\n          `GitHub API ${method} ${path} failed with ${response.status}: ${formatApiError(data)}`\n        )\n      }\n\n      return data\n    }\n  }\n}\n\nfunction readWorkflowRunFromDispatchResult(result) {\n  if (Number.isInteger(result?.workflow_run_id)) {\n    return {\n      html_url: result.html_url,\n      id: result.workflow_run_id\n    }\n  }\n\n  return null","sourceCodeStart":152,"sourceCodeEnd":188,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/config/scripts/run-release-mac-build-workflow.mjs#L152-L188","documentation":"Thrown by the api.request method when the GitHub API response is not ok (status outside 2xx). The message includes method, path, the HTTP status, and the API's error payload (data.message if present, else JSON.stringify(data)). This wraps any non-success GitHub REST response into a single error shape.","triggerScenarios":"Any api.request(method, path, body) that yields response.ok === false: 401/403 auth or scopes, 404 wrong workflow/repo path, 422 malformed inputs, 409/500 server errors, or secondary rate limits (403 with a rate-limit message).","commonSituations":"Expired or under-scoped GITHUB_TOKEN, dispatching a workflow that does not exist (404 on .../dispatches), wrong ref (RELEASE_MAC_BUILD_REF), per-second rate limiting, dispatching to a repo the token cannot access.","solutions":["For 401/403, verify GITHUB_TOKEN/GH_TOKEN is valid and has actions:write and contents:read scopes.","For 404, confirm options.workflow file name and that the ref exists in the repo.","For 403 rate limit, back off and retry; consider condensing calls.","Read the data.message in the error to map the status to the GitHub reason."],"exampleFix":"// before\nawait api.request('POST', `/repos/${owner}/${repo}/actions/workflows/${wf}/dispatches`, body)\n// after\ntry {\n  await api.request('POST', `/repos/${owner}/${repo}/actions/workflows/${encodeURIComponent(wf)}/dispatches`, body)\n} catch (err) {\n  // err.message: 'GitHub API POST .../dispatches failed with 404: Not Found'\n  throw err\n}","handlingStrategy":"try-catch","validationCode":"function canDispatch(api, options) {\n  return Boolean(options.token && options.repo && options.workflow && options.ref)\n}\nif (!canDispatch(null, options)) {\n  throw new Error('Missing token/repo/workflow/ref; cannot dispatch')\n}","typeGuard":"function isApiErrorStatus(method, path, status) {\n  return status === 401 || status === 403 || status === 404 || status === 422 || status >= 500\n}","tryCatchPattern":"try {\n  await api.request('POST', path, body)\n} catch (err) {\n  const m = err.message.match(/failed with (\\d+):/)\n  if (m) {\n    const status = Number(m[1])\n    if (status === 403 && /rate limit/i.test(err.message)) await sleep(backoffMs) // retry\n    else if (status >= 500) await sleep(backoffMs) // retry once\n    else throw err // 4xx is fatal\n  } else throw err\n}","preventionTips":["Verify GITHUB_TOKEN scopes (actions:write, contents:read) before dispatch.","Confirm the workflow file name and ref exist (avoid 404).","Add bounded retry with backoff for 403-rate-limit and 5xx; never retry 4xx.","Log status + data.message to map failures to GitHub reasons quickly."],"tags":["github-api","network","auth","rate-limit","http"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}