jackwener/OpenCLI · error · CommandExecutionError

Suno feed lookup returned malformed clips payload

Error message

Suno feed lookup returned malformed clips payload

What it means

A defensive second check: even when the feed fetch reports ok, the CLI re-validates that `result.clips` is an array before slicing/mapping. It throws if the payload shape is unusable.

Source

Thrown at clis/suno/list.js:59

            const browserToken = JSON.stringify({ token: btoa(JSON.stringify({ timestamp: Date.now() })) });
            const res = await fetch('${STUDIO_API}/api/feed/v2?page=${pageOffset}', {
                headers: {
                    'Authorization': 'Bearer ' + (await window.Clerk.session.getToken()),
                    'browser-token': browserToken,
                    'device-id': ${JSON.stringify(deviceId)},
                },
            });
            if (!res.ok) return { ok: false, status: res.status };
            const data = await res.json().catch(() => null);
            if (!data || !Array.isArray(data.clips)) return { ok: false, error: 'malformed clips payload' };
            return { ok: true, clips: data.clips };
        })()`));

        if (!result?.ok) {
            throw new CommandExecutionError(result?.error || `Suno feed lookup failed (HTTP ${result?.status || '?'}).`);
        }
        if (!Array.isArray(result.clips)) {
            throw new CommandExecutionError('Suno feed lookup returned malformed clips payload');
        }
        if (result.clips.length === 0) {
            throw new EmptyResultError('suno list', 'No Suno clips found in your library.');
        }

        return result.clips.slice(0, limit).map((c, i) => {
            if (!c || typeof c.id !== 'string' || !c.id) {
                throw new CommandExecutionError('Suno feed lookup returned malformed clip identity');
            }
            return {
                rank: i + 1 + pageOffset * limit,
                clip: c.id.slice(0, 8),
                title: c.title || '(untitled)',
                status: c.status || '?',
                created: (c.created_at || '').replace('T', ' ').replace(/\..*$/, '').replace(/Z$/, ''),
                link: `${SUNO_URL}/song/${c.id}`,
            };
        });

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Log the raw evaluate result from unwrapEvaluateResult to see the actual shape.
  2. Check for opencli/Suno schema drift and update the parsing code.
  3. Retry the command — if intermittent, it may be a serialization hiccup in the page bridge.

Example fix

// before: blind trust
const first = result.clips[0];
// after
if (!Array.isArray(result.clips)) throw new Error('unexpected feed payload: ' + JSON.stringify(result));
const first = result.clips[0];
Defensive patterns

Strategy: type-guard

Validate before calling

const result = unwrapEvaluateResult(await page.evaluate(feedScript));
if (!result || typeof result !== 'object') throw new Error('feed bridge returned non-object');

Type guard

function isFeedResultOk(r) { return !!r && r.ok === true && Array.isArray(r.clips); }

Try / catch

try {
  const clips = await listSunoClips();
} catch (e) {
  if (/malformed clips payload/.test(e.message)) {
    logRawBridgeResultForDebugging();
    throw new Error('Suno feed schema drift or page-bridge issue — inspect raw payload');
  }
  throw e;
}

Prevention

When it happens

Trigger: `result.ok === true` but `result.clips` is not an array — practically unreachable via the in-page evaluate (which already validates), but guards against unwrapEvaluateResult returning an unexpected shape.

Common situations: Tooling/hydration mismatch where unwrapEvaluateResult returns a non-standard object, or future refactors that bypass the in-page shape check.

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/4875fa3f47fc08e6. Report an issue: GitHub.