jackwener/OpenCLI · error · CommandExecutionError

Suno generation returned malformed clips payload.

Error message

Suno generation returned malformed clips payload.

What it means

After submitting, the CLI validates that `submission.clips` is an array. If Suno's /api/generate response lacks a clips array (unexpected shape, auth payload, or error body), this CommandExecutionError is thrown instead of failing later with a confusing TypeError.

Source

Thrown at clis/suno/generate.js:170

        const submission = await submitSunoGeneration(page, {
            mode: isCustom ? 'custom' : 'simple',
            model,
            title,
            lyrics,
            tags,
            negativeTags,
            description,
            makeInstrumental,
            weirdness,
            styleWeight,
            userTier: session.planId,
            createSessionToken,
            transactionUuid,
            deviceId,
        });

        if (!Array.isArray(submission.clips)) {
            throw new CommandExecutionError('Suno generation returned malformed clips payload.');
        }
        const clipIds = submission.clips.map(c => c?.id);
        if (clipIds.some(id => !id)) {
            throw new CommandExecutionError('Suno generation returned malformed clip identity.');
        }
        if (!clipIds.length) {
            throw new CommandExecutionError('Suno accepted the request but returned no clip ids.');
        }

        const clips = await pollSunoClips(page, clipIds, timeout, deviceId);
        const completed = clips.filter(c => c.status === 'complete');
        if (!completed.length) {
            const errors = clips.map(c => `${c.id.slice(0, 8)}:${c.status}`).join(', ');
            throw new CommandExecutionError(`All Suno clips failed (${errors}). Open ${SUNO_URL}/song/${clipIds[0]} to inspect.`);
        }

        const rows = [];
        for (const clip of clips) {

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Log/inspect the full submission payload to see what Suno actually returned.
  2. Re-login in the browser profile to refresh cookies and Clerk session token, then retry.
  3. Check if Suno changed the /api/generate/v2-web/ response schema and update the CLI parsing.
  4. Retry later — a transient Suno incident may be returning error bodies.

Example fix

// before: assumes clips exists
const ids = submission.clips.map(c => c.id);
// after: validate first
if (!Array.isArray(submission?.clips)) throw new Error('malformed clips payload: ' + JSON.stringify(submission).slice(0, 500));
const ids = submission.clips.map(c => c?.id);
Defensive patterns

Strategy: type-guard

Validate before calling

const submission = await submitSunoGeneration(page, params);
if (!submission || typeof submission !== 'object') throw new Error('generate returned non-object');
if (!Array.isArray(submission.clips)) throw new Error('no clips array: ' + JSON.stringify(submission).slice(0, 500));

Type guard

function isClipsPayload(v) { return !!v && typeof v === 'object' && Array.isArray(v.clips); }

Try / catch

try {
  const submission = await submitSunoGeneration(page, params);
  if (!isClipsPayload(submission)) throw new Error('Suno API schema drift — inspect raw payload');
} catch (e) {
  logger.error({ payload: e.submission }, 'suno generate payload invalid');
  throw e;
}

Prevention

When it happens

Trigger: `submitSunoGeneration()` returns an object whose `clips` field is not an array — e.g. Suno returned an error envelope, HTML, or a schema drift in the v2-web generate endpoint.

Common situations: Suno API contract change after a site update, session silently expired so an auth error JSON was returned, or the in-page fetch was intercepted by a bot-protection response.

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.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/c8114fc01ad6807f. Report an issue: GitHub.