{"record":{"id":"1c8b970ede12d8c3","repo":"jackwener/OpenCLI","slug":"minimax-music-response-is-missing-integer-base-res","errorCode":null,"errorMessage":"MiniMax music response is missing integer base_resp.status_code","messagePattern":"MiniMax music response is missing integer base_resp\\.status_code","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/minimax/utils.js","lineNumber":88,"sourceCode":"        throw new AuthRequiredError(region.host, `MiniMax ${region.host} rejected ${MINIMAX_API_KEY_VAR} (HTTP ${response.status}).`);\n    }\n    if (!response.ok) {\n        throw new CommandExecutionError(`MiniMax music returned HTTP ${response.status} from ${region.host}`);\n    }\n    try {\n        return await response.json();\n    } catch (error) {\n        throw new CommandExecutionError(`MiniMax music returned malformed JSON: ${error?.message ?? error}`);\n    }\n}\n\nexport function parseCompletedMusic(payload, region) {\n    if (!payload || typeof payload !== 'object' || Array.isArray(payload)) {\n        throw new CommandExecutionError('MiniMax music returned a malformed response envelope');\n    }\n    const base = payload.base_resp;\n    if (!base || typeof base !== 'object' || !Number.isInteger(base.status_code)) {\n        throw new CommandExecutionError('MiniMax music response is missing integer base_resp.status_code');\n    }\n    if (base.status_code !== 0) {\n        const message = typeof base.status_msg === 'string' && base.status_msg.trim()\n            ? `: ${base.status_msg.trim()}`\n            : '';\n        if (AUTH_CODES.has(base.status_code)) {\n            throw new AuthRequiredError(region.host, `MiniMax ${region.host} rejected ${MINIMAX_API_KEY_VAR} (service ${base.status_code}${message}).`);\n        }\n        throw new CommandExecutionError(`MiniMax music failed (service ${base.status_code}${message})`);\n    }\n    const data = payload.data;\n    if (!data || typeof data !== 'object' || Array.isArray(data) || !Number.isInteger(data.status)) {\n        throw new CommandExecutionError('MiniMax music response is missing integer data.status');\n    }\n    if (data.status === 1) {\n        const traceId = typeof payload.trace_id === 'string' && /^[A-Za-z0-9_-]{1,128}$/.test(payload.trace_id.trim())\n            ? payload.trace_id.trim()\n            : '';","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/minimax/utils.js#L70-L106","documentation":"A CommandExecutionError thrown by parseCompletedMusic() when payload.base_resp is missing, not an object, or lacks an integer status_code. base_resp.status_code is MiniMax's service-level result code; without it the library cannot distinguish success from failure, so it refuses to guess.","triggerScenarios":"The response object exists but base_resp is absent/null, a non-object, or its status_code is a string/float/undefined — e.g. {data: {...}} without base_resp, or {base_resp: {status_code: \"0\"}}.","commonSituations":"API version drift where MiniMax renames or nests the status field; intermediaries stripping fields; tests with hand-written fixtures omitting base_resp; non-music MiniMax endpoints' bodies accidentally routed into the music parser.","solutions":["Dump the full raw JSON and verify the expected {base_resp:{status_code,status_msg}, data:{...}} shape for the v1 music_generation endpoint.","Confirm you are hitting /v1/music_generation, not another MiniMax product endpoint with a different envelope.","Update the CLI/library if MiniMax changed the schema; check for a newer release.","Fix test fixtures or scripts to include base_resp with an integer status_code."],"exampleFix":"// before (fixture)\n{data: {status: 2, audio: \"...\"}}\n\n// after\n{base_resp: {status_code: 0, status_msg: \"success\"}, data: {status: 2, audio: \"...\"}}","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"function hasBaseResp(v) {\n  return v != null && typeof v === 'object' && !Array.isArray(v)\n    && v.base_resp != null && typeof v.base_resp === 'object'\n    && Number.isInteger(v.base_resp.status_code);\n}","tryCatchPattern":"try {\n  const done = parseCompletedMusic(payload, region);\n} catch (e) {\n  if (e instanceof CommandExecutionError && /base_resp.status_code/.test(e.message)) {\n    // dump raw JSON, confirm endpoint is /v1/music_generation, retry/update client\n  } else throw e;\n}","preventionTips":["Point only at the official /v1/music_generation endpoint.","Validate fixtures include base_resp with integer status_code.","Keep the CLI/library updated for MiniMax schema changes.","Log raw JSON on unexpected shapes to speed triage."],"tags":["schema-validation","response-parsing","api-change"],"backgroundTag":"schema-validation-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}