{"record":{"id":"652906825cbecb89","repo":"chatboxai/chatbox","slug":"json-stringify-json-652906","errorCode":null,"errorMessage":"JSON.stringify(json)","messagePattern":"JSON\\.stringify\\(json\\)","errorType":"http","errorClass":"ApiError","httpStatus":null,"severity":"error","filePath":"src/shared/providers/definitions/models/claude.ts","lineNumber":167,"sourceCode":"    }\n    const url = `${this.options.claudeApiHost}/models?limit=990`\n    const headers: Record<string, string> = {\n      'anthropic-version': '2023-06-01',\n      ...this.options.extraHeaders,\n    }\n    if (this.options.authToken) {\n      headers['Authorization'] = `Bearer ${this.options.authToken}`\n    } else if (this.options.claudeApiKey) {\n      headers['x-api-key'] = this.options.claudeApiKey\n    }\n    const res = await this.dependencies.request.apiRequest({\n      url: url,\n      method: 'GET',\n      headers,\n    })\n    const json: Response = await res.json()\n    if (!json['data']) {\n      throw new ApiError(JSON.stringify(json))\n    }\n    return json['data']\n      .filter((item) => item.type === 'model')\n      .map((item) => ({\n        modelId: item.id,\n        type: 'chat',\n      }))\n  }\n}\n\nfunction parseJsonObject(value: string): Record<string, unknown> | undefined {\n  try {\n    const parsed = JSON.parse(value)\n    return isRecord(parsed) ? parsed : undefined\n  } catch {\n    return undefined\n  }\n}","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/chatboxai/chatbox/blob/81571269addb6bafb589a920b2883f1e1e084fd1/src/shared/providers/definitions/models/claude.ts#L149-L185","documentation":"Error \"JSON.stringify(json)\" thrown in chatboxai/chatbox.","triggerScenarios":"Thrown at src/shared/providers/definitions/models/claude.ts:167 when the library encounters an invalid state.","commonSituations":"Occurs in src/shared/providers/definitions/models/claude.ts when the Anthropic API returns a non-success response whose body is serialized with JSON.stringify and thrown as an ApiError.","solutions":["Check that the Claude API host is reachable and correct in provider settings.","Verify the API key or OAuth token is valid and has not expired.","Inspect the stringified response body for the upstream error message (e.g. authentication_error, permission_error).","If using a custom relay or proxy, confirm it returns the standard Anthropic /models response shape with a 'data' array."],"exampleFix":"const json: Response = await res.json()\nif (!json['data']) {\n  // json contains the upstream error; surface it and check credentials\n  console.error('Claude listModels error:', json)\n}","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"81571269addb6bafb589a920b2883f1e1e084fd1","analyzedAt":"2026-08-12T21:51:44.981Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}