Kong/insomnia · error · ResponseFailError
CODE
Error message
CODE-${error.response.status} What it means
Thrown by mapSdkError in the spaces API client when the backend responds with a non-2xx status; it wraps the HTTP status into a CODE-<status> error name so callers can branch on the numeric code (401 unauthenticated, 403 wrong org, 5xx backend failure).
Solutions
- Inspect the numeric status: 401/403 means re-authenticate or verify org/space access; 404 means the space id is wrong; 5xx means retry later
- Check the ResponseFailError message body for the backend-provided error detail
- Verify network/proxy connectivity to the API base URL
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at packages/insomnia-api/src/spaces.ts:72 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of Kong/insomnia@d9bb2b0142 (2026-08-26).
Data as JSON: /api/errors/1502ba075624e26b.
Report an issue: GitHub.
Appendix: source
Thrown at packages/insomnia-api/src/spaces.ts:72
}
// `nextUri` is a path like `/v3/users/me/spaces?page[size]=20&page[after]=...`.
// URL needs an absolute base to parse; resolve against the same backend the SDK is configured against.
const url = new URL(nextUri, v3Config.getBaseURL());
return url.searchParams.get('page[after]') ?? undefined;
}
async function readProblemJson(response: Response): Promise<{ title?: string; detail?: string }> {
try {
return await response.clone().json();
} catch {
return {};
}
}
async function mapSdkError(error: unknown): Promise<never> {
if (error instanceof ResponseError) {
const { title, detail } = await readProblemJson(error.response);
throw new ResponseFailError(title || `CODE-${error.response.status}`, detail || error.response.statusText, error.response);
}
throw error;
}
/**
* Lists every space the current user is a member of, paginating through cursors.
*
* TODO: switch callers to true pagination — fetch the first page only and expose
* the cursor so the UI can request more on demand instead of fetching everything
* up front. Requires UI changes to handle progressive loading.
*/
export const getSpaces = async ({ sessionId }: { sessionId: string }): Promise<Space[]> => {
const client = buildClient(sessionId);
const all: Space[] = [];
let pageAfter: string | undefined;
try {
do {
const response: ListCurrentUserSpaces200Response = await client.listCurrentUserSpaces({View on GitHub (pinned to d9bb2b0142)