jackwener/OpenCLI · error · CommandExecutionError
MiniMax music returned a malformed response envelope
Error message
MiniMax music returned a malformed response envelope
What it means
A CommandExecutionError thrown by parseCompletedMusic() when the parsed JSON body is not a plain object — null, an array, or a non-object. MiniMax music responses must follow the {base_resp: {...}} envelope, so anything else cannot be interpreted as a generation result.
Source
Thrown at clis/minimax/utils.js:84
} finally {
clearTimeout(timer);
}
if (response.status === 401 || response.status === 403) {
throw new AuthRequiredError(region.host, `MiniMax ${region.host} rejected ${MINIMAX_API_KEY_VAR} (HTTP ${response.status}).`);
}
if (!response.ok) {
throw new CommandExecutionError(`MiniMax music returned HTTP ${response.status} from ${region.host}`);
}
try {
return await response.json();
} catch (error) {
throw new CommandExecutionError(`MiniMax music returned malformed JSON: ${error?.message ?? error}`);
}
}
export function parseCompletedMusic(payload, region) {
if (!payload || typeof payload !== 'object' || Array.isArray(payload)) {
throw new CommandExecutionError('MiniMax music returned a malformed response envelope');
}
const base = payload.base_resp;
if (!base || typeof base !== 'object' || !Number.isInteger(base.status_code)) {
throw new CommandExecutionError('MiniMax music response is missing integer base_resp.status_code');
}
if (base.status_code !== 0) {
const message = typeof base.status_msg === 'string' && base.status_msg.trim()
? `: ${base.status_msg.trim()}`
: '';
if (AUTH_CODES.has(base.status_code)) {
throw new AuthRequiredError(region.host, `MiniMax ${region.host} rejected ${MINIMAX_API_KEY_VAR} (service ${base.status_code}${message}).`);
}
throw new CommandExecutionError(`MiniMax music failed (service ${base.status_code}${message})`);
}
const data = payload.data;
if (!data || typeof data !== 'object' || Array.isArray(data) || !Number.isInteger(data.status)) {
throw new CommandExecutionError('MiniMax music response is missing integer data.status');
}View on GitHub (pinned to 49907e53dc)
Solutions
- Log the raw HTTP body before parsing to confirm what MiniMax actually returned.
- Retry the generation — a one-off gateway artifact often resolves on resubmission (check account history first to avoid double billing).
- Check MiniMax API changelog/docs for envelope changes if this recurs systematically.
- If you feed parseCompletedMusic manually (tests, scripts), pass the full response object, not a sub-field.
Example fix
// before
done(payload.data); // wrong: sub-object, envelope lost
// after
done(payload); // pass the full {base_resp, data} envelope Defensive patterns
Strategy: type-guard
Type guard
function isMusicEnvelope(v) {
return v != null && typeof v === 'object' && !Array.isArray(v);
}
// guard before parsing
if (!isMusicEnvelope(raw)) throw new Error('Unexpected non-object MiniMax response'); Try / catch
try {
const done = parseCompletedMusic(payload, region);
} catch (e) {
if (e instanceof CommandExecutionError && /malformed response envelope/.test(e.message)) {
// log raw body, then retry the generation once
} else throw e;
} Prevention
- Always pass the full parsed response object to parseCompletedMusic, never a sub-field.
- Keep fixtures in tests shaped like real MiniMax envelopes.
- Watch MiniMax changelogs for envelope schema changes.
When it happens
Trigger: parseCompletedMusic(payload) is called (via the completed step) with a payload that is null, undefined, an Array, or a primitive — e.g. the endpoint returned JSON like "ok", [], or null with HTTP 200, and that body was passed straight through.
Common situations: MiniMax changing or versioning their response schema; a gateway returning a bare JSON literal with 200; mocking/stubbing in tests that supplies the wrong envelope shape; proxy middleware rewriting bodies.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- MiniMax music response is missing integer base_resp.status_c
- WeRead book search returned malformed books
- returned malformed items payload
- LinkedIn connection miniProfile field ${field} was malformed
- LinkedIn connections API returned a malformed payload: missi
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/0945637673498f06.
Report an issue: GitHub.