{"record":{"id":"995b4fc4077b044e","repo":"chatboxai/chatbox","slug":"json-stringify-json-995b4f","errorCode":null,"errorMessage":"JSON.stringify(json)","messagePattern":"JSON\\.stringify\\(json\\)","errorType":"http","errorClass":"ApiError","httpStatus":null,"severity":"error","filePath":"src/shared/providers/definitions/models/gemini.ts","lineNumber":169,"sourceCode":"        version: string\n        displayName: string\n        description: string\n        inputTokenLimit: number\n        outputTokenLimit: number\n        supportedGenerationMethods: string[]\n        temperature: number\n        topP: number\n        topK: number\n      }[]\n    }\n    const res = await this.dependencies.request.apiRequest({\n      url: `${this.options.geminiAPIHost}/v1beta/models?key=${this.options.geminiAPIKey}`,\n      method: 'GET',\n      headers: {},\n    })\n    const json: Response = await res.json()\n    if (!json.models) {\n      throw new ApiError(JSON.stringify(json))\n    }\n    return json.models\n      .filter((m) => m.supportedGenerationMethods.some((method) => method.includes('generate')))\n      .filter((m) => m.name.includes('gemini'))\n      .map((m) => ({\n        modelId: m.name.replace('models/', ''),\n        nickname: m.displayName,\n        type: 'chat' as const,\n        contextWindow: m.inputTokenLimit,\n        maxOutput: m.outputTokenLimit,\n      }))\n      .sort((a, b) => a.modelId.localeCompare(b.modelId))\n  }\n}\n","sourceCodeStart":151,"sourceCodeEnd":184,"githubUrl":"https://github.com/chatboxai/chatbox/blob/81571269addb6bafb589a920b2883f1e1e084fd1/src/shared/providers/definitions/models/gemini.ts#L151-L184","documentation":"Error \"JSON.stringify(json)\" thrown in chatboxai/chatbox.","triggerScenarios":"Thrown at src/shared/providers/definitions/models/gemini.ts:169 when the library encounters an invalid state.","commonSituations":"Occurs in src/shared/providers/definitions/models/gemini.ts when the Gemini API returns an error response whose JSON body is thrown as an ApiError.","solutions":["Verify the Gemini API key is valid and the Generative Language API is enabled for the project.","Check that geminiAPIHost is correct and reachable.","Inspect the stringified response body for the upstream error message.","Confirm the response contains a 'models' array; a proxy or captive portal may be returning something else."],"exampleFix":"const json: Response = await res.json()\nif (!json.models) {\n  console.error('Gemini 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"}