gitbutlerapp/gitbutler · error
Error
Error message
Error ${error.response.status}: ${error.message} What it means
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.
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).
Example fix
// before
throw new Error(`Error ${error.response.status}: ${error.message}`);
// after
if (error.response.status === 401 || error.response.status === 403) {
return { type: "unauthorized" };
}
if (error.response.status >= 500 || error.response.status === 429) {
return { type: "retryable", status: error.response.status };
}
throw new Error(`Owner fetch failed: HTTP ${error.response.status}: ${error.response.data ?? error.message}`); Defensive patterns
Strategy: try-catch
Try / catch
try {
const owner = await fetchOwner(id);
} catch (e) {
if (e instanceof Error && /^Error \d{3}:/.test(e.message)) {
const status = Number(e.message.match(/\d{3}/)?.[0]);
if (status === 401 || status === 403) redirect to login;
else if (status === 429 || status >= 500) scheduleRetry();
} else throw e;
} Prevention
- 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.
When it happens
Trigger: 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>`.
Common situations: 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.
Understand the failure class
Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.
Related errors
- Anthropic API error ( )
- Failed to add labels
- Failed to add to GitHub stack
- Failed to create GitHub stack
- Failed to create merge request
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/3c147a42f092cb7d.
Report an issue: GitHub.
Appendix: source
Thrown at apps/web/src/lib/owner/ownerService.ts:106
};
return {
type: "user",
data: user,
};
}
// If owner_type is not set or unknown, return not found
return { type: "not_found" };
} catch (error: any) {
if (error.response) {
// Return not_found for 404s
if (error.response.status === 404) {
return { type: "not_found" };
}
// For all other error status codes, throw the error
throw new Error(`Error ${error.response.status}: ${error.message}`);
}
// For network errors or other non-HTTP errors
throw error;
}
}
}
View on GitHub (pinned to 58e5313667)