{"record":{"id":"3f37e8304898b35d","repo":"CherryHQ/cherry-studio","slug":"invalid-json-response-from-minimax","errorCode":null,"errorMessage":"Invalid JSON response from MiniMax","messagePattern":"Invalid JSON response from MiniMax","errorType":"exception","errorClass":"APICallError","httpStatus":null,"severity":"error","filePath":"src/main/ai/provider/custom/minimax/minimaxImageModel.ts","lineNumber":105,"sourceCode":"    const headersRecord = responseHeaders(response)\n    const responseBody = await response.text()\n\n    if (!response.ok) {\n      throw new APICallError({\n        message: responseBody || response.statusText,\n        url,\n        requestBodyValues: body,\n        statusCode: response.status,\n        responseHeaders: headersRecord,\n        responseBody\n      })\n    }\n\n    let parsed: MinimaxImageResponse\n    try {\n      parsed = JSON.parse(responseBody) as MinimaxImageResponse\n    } catch (cause) {\n      throw new APICallError({\n        message: 'Invalid JSON response from MiniMax',\n        cause,\n        url,\n        requestBodyValues: body,\n        statusCode: response.status,\n        responseHeaders: headersRecord,\n        responseBody\n      })\n    }\n\n    if (parsed.base_resp?.status_code && parsed.base_resp.status_code !== 0) {\n      throw new APICallError({\n        message: parsed.base_resp.status_msg || `MiniMax error ${parsed.base_resp.status_code}`,\n        url,\n        requestBodyValues: body,\n        statusCode: response.status,\n        responseHeaders: headersRecord,\n        responseBody","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/CherryHQ/cherry-studio/blob/726446b54cd69ffe51a276638672f6d95ca0768c/src/main/ai/provider/custom/minimax/minimaxImageModel.ts#L87-L123","documentation":"Thrown as an `APICallError` when `JSON.parse` fails on a 2xx MiniMax response body. A successful HTTP status with a non-JSON body means the response did not come from the MiniMax image API as expected — the original `parse` error is chained as `cause`, and the raw body is preserved on the error for inspection.","triggerScenarios":"A proxy or CDN returned an HTML error page with 200; MiniMax returned a maintenance/interstitial page; a gateway between the app and MiniMax altered the response; an empty or truncated body.","commonSituations":"Corporate proxy intercepting the request; MiniMax briefly serving a non-API page during an incident; a response truncation from a network glitch; misconfigured `baseURL` pointing at a web page.","solutions":["Inspect `error.responseBody` to see what was actually returned (HTML, empty, truncated).","Verify the MiniMax `baseURL`/endpoint is correct and points at the API host, not a web page.","Retry — transient proxy/maintenance pages often clear up; if persistent, check network/proxy config."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"const isInvalidJsonError = (e: unknown): boolean =>\n  e instanceof APICallError && /Invalid JSON response/.test(e.message)","tryCatchPattern":"try {\n  await model.doGenerate(opts)\n} catch (e) {\n  if (e instanceof APICallError && /Invalid JSON response/.test(e.message)) {\n    // inspect e.responseBody — likely a proxy/maintenance page; retry\n  }\n  throw e\n}","preventionTips":["Verify the MiniMax baseURL points at the API host, not a web page","Retry once for transient proxy/maintenance pages","Log responseBody to diagnose non-JSON returns"],"tags":["parse","json","minimax","proxy","response-shape"],"backgroundTag":null,"analyzedSha":"726446b54cd69ffe51a276638672f6d95ca0768c","analyzedAt":"2026-08-12T17:30:37.448Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}