{"record":{"id":"1502ba075624e26b","repo":"Kong/insomnia","slug":"code-error-response-status","errorCode":null,"errorMessage":"CODE-${error.response.status}","messagePattern":"CODE-\\$\\{error\\.response\\.status\\}","errorType":"exception","errorClass":"ResponseFailError","httpStatus":null,"severity":"error","filePath":"packages/insomnia-api/src/spaces.ts","lineNumber":72,"sourceCode":"  }\n  // `nextUri` is a path like `/v3/users/me/spaces?page[size]=20&page[after]=...`.\n  // URL needs an absolute base to parse; resolve against the same backend the SDK is configured against.\n  const url = new URL(nextUri, v3Config.getBaseURL());\n  return url.searchParams.get('page[after]') ?? undefined;\n}\n\nasync function readProblemJson(response: Response): Promise<{ title?: string; detail?: string }> {\n  try {\n    return await response.clone().json();\n  } catch {\n    return {};\n  }\n}\n\nasync function mapSdkError(error: unknown): Promise<never> {\n  if (error instanceof ResponseError) {\n    const { title, detail } = await readProblemJson(error.response);\n    throw new ResponseFailError(title || `CODE-${error.response.status}`, detail || error.response.statusText, error.response);\n  }\n  throw error;\n}\n\n/**\n * Lists every space the current user is a member of, paginating through cursors.\n *\n * TODO: switch callers to true pagination — fetch the first page only and expose\n * the cursor so the UI can request more on demand instead of fetching everything\n * up front. Requires UI changes to handle progressive loading.\n */\nexport const getSpaces = async ({ sessionId }: { sessionId: string }): Promise<Space[]> => {\n  const client = buildClient(sessionId);\n  const all: Space[] = [];\n  let pageAfter: string | undefined;\n  try {\n    do {\n      const response: ListCurrentUserSpaces200Response = await client.listCurrentUserSpaces({","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/Kong/insomnia/blob/d9bb2b0142600f21309832daea3317942d285984/packages/insomnia-api/src/spaces.ts#L54-L90","documentation":"Error \"CODE-${error.response.status}\" thrown in Kong/insomnia.","triggerScenarios":"Thrown at packages/insomnia-api/src/spaces.ts:72 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"d9bb2b0142600f21309832daea3317942d285984","analyzedAt":"2026-08-26T18:04:05.187Z","schemaVersion":2},"datasetVersion":"2026-08-26T21:11:00.512Z"}