{"record":{"id":"3c147a42f092cb7d","repo":"gitbutlerapp/gitbutler","slug":"error-error-response-status-error-message","errorCode":null,"errorMessage":"Error ${error.response.status}: ${error.message}","messagePattern":"Error (.+?): (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"apps/web/src/lib/owner/ownerService.ts","lineNumber":106,"sourceCode":"\t\t\t\t};\n\n\t\t\t\treturn {\n\t\t\t\t\ttype: \"user\",\n\t\t\t\t\tdata: user,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\t// If owner_type is not set or unknown, return not found\n\t\t\treturn { type: \"not_found\" };\n\t\t} catch (error: any) {\n\t\t\tif (error.response) {\n\t\t\t\t// Return not_found for 404s\n\t\t\t\tif (error.response.status === 404) {\n\t\t\t\t\treturn { type: \"not_found\" };\n\t\t\t\t}\n\n\t\t\t\t// For all other error status codes, throw the error\n\t\t\t\tthrow new Error(`Error ${error.response.status}: ${error.message}`);\n\t\t\t}\n\n\t\t\t// For network errors or other non-HTTP errors\n\t\t\tthrow error;\n\t\t}\n\t}\n}\n","sourceCodeStart":88,"sourceCodeEnd":114,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/apps/web/src/lib/owner/ownerService.ts#L88-L114","documentation":"fetchOwner wraps an axios GET for owner data. A 404 is normalized to { type: \"not_found\" }, but any other HTTP error status (401, 403, 500, etc.) is rethrown as a plain Error with the status code and axios message. Callers (the store) must handle this throw; it signals the owner API responded with a non-404 failure status.","triggerScenarios":"The owner endpoint returns a status other than 404 with error.response set: 401/403 for auth problems, 429 rate limiting, 5xx server errors — axios rejects and the catch branch builds `Error <status>: <axios message>`.","commonSituations":"Expired/invalid auth token yielding 401 or 403; backend outage or bug returning 500; rate limiter returning 429; gateway returning 502/503 during deploys; calling an endpoint with a wrong owner id that the server rejects with 400.","solutions":["Check error.response.status in the calling store and handle 401/403 by refreshing credentials or redirecting to login.","Inspect the actual HTTP response body (browser devtools/network tab) to see the server's error payload.","Retry with backoff for transient 429/5xx statuses.","Verify the request URL and owner identifier are correct (a bad id can produce 400/403)."],"exampleFix":"// before\nthrow new Error(`Error ${error.response.status}: ${error.message}`);\n\n// after\nif (error.response.status === 401 || error.response.status === 403) {\n  return { type: \"unauthorized\" };\n}\nif (error.response.status >= 500 || error.response.status === 429) {\n  return { type: \"retryable\", status: error.response.status };\n}\nthrow new Error(`Owner fetch failed: HTTP ${error.response.status}: ${error.response.data ?? error.message}`);","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const owner = await fetchOwner(id);\n} catch (e) {\n  if (e instanceof Error && /^Error \\d{3}:/.test(e.message)) {\n    const status = Number(e.message.match(/\\d{3}/)?.[0]);\n    if (status === 401 || status === 403) redirect to login;\n    else if (status === 429 || status >= 500) scheduleRetry();\n  } else throw e;\n}","preventionTips":["Normalize HTTP error statuses into typed results at the service boundary rather than string messages.","Refresh auth tokens proactively to avoid 401/403 responses.","Add retry-with-backoff for 429 and 5xx statuses.","Log response bodies to correlate thrown messages with server-side error payloads."],"tags":["http","api","axios"],"backgroundTag":"http-error-response","analyzedSha":"58e5313667b857ef39a730e380af31816a7b1768","analyzedAt":"2026-09-18T06:50:32.052Z","contentChangedAt":"2026-09-18T06:50:32.052Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}