{"record":{"id":"56dc032940fe3c56","repo":"chatboxai/chatbox","slug":"json-stringify-json-56dc03","errorCode":null,"errorMessage":"JSON.stringify(json)","messagePattern":"JSON\\.stringify\\(json\\)","errorType":"http","errorClass":"ApiError","httpStatus":null,"severity":"error","filePath":"src/shared/providers/definitions/models/custom-gemini.ts","lineNumber":180,"sourceCode":"        supportedGenerationMethods: string[]\n        temperature: number\n        topP: number\n        topK: number\n      }[]\n    }\n\n    try {\n      const { apiHost } = normalizeGeminiHost(this.options.apiHost)\n      const res = await this.dependencies.request.apiRequest({\n        url: `${apiHost}/models?key=${this.options.apiKey}`,\n        method: 'GET',\n        useProxy: this.options.useProxy,\n        headers: {},\n      })\n      const json: Response = await res.json()\n\n      if (!json.models) {\n        throw new ApiError(JSON.stringify(json))\n      }\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    } catch (error) {\n      console.error('Failed to fetch Gemini models:', error)\n      return []\n    }\n  }","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/chatboxai/chatbox/blob/81571269addb6bafb589a920b2883f1e1e084fd1/src/shared/providers/definitions/models/custom-gemini.ts#L162-L198","documentation":"Error \"JSON.stringify(json)\" thrown in chatboxai/chatbox.","triggerScenarios":"Thrown at src/shared/providers/definitions/models/custom-gemini.ts:180 when the library encounters an invalid state.","commonSituations":"Occurs in src/shared/providers/definitions/models/custom-gemini.ts when the custom Gemini endpoint returns an error response whose JSON body is thrown as an ApiError.","solutions":["Check that the custom Gemini API host is correct and reachable.","Verify the API key passed in the /models?key= query is valid and has Generative Language API access.","Inspect the stringified response body for the upstream error (e.g. API_KEY_INVALID).","Confirm the endpoint returns the standard Gemini list-models shape with a 'models' array."],"exampleFix":"const json: Response = await res.json()\nif (!json.models) {\n  console.error('Custom 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"}