jackwener/OpenCLI · error · CommandExecutionError
Pinterest request returned malformed API payload
Error message
Pinterest request returned malformed API payload
What it means
The raw response parsed as JSON but lacks the expected resource_response object that Pinterest's resource API normally returns. The library throws CommandExecutionError because it cannot extract data/results/bookmark without it.
Source
Thrown at clis/pinterest/utils.js:233
// link of a scraped pin), so pass its own message through instead of only saying "log in".
throw new AuthRequiredError(
PINTEREST_DOMAIN,
raw.message
? `Pinterest refused this write: ${raw.message}`
: 'This action requires being logged in to Pinterest in Chrome',
);
}
const hint = status === 403 ? ' (missing or expired CSRF token — reload Pinterest in Chrome)' : '';
// Surface Pinterest's own error text (from resource_response.error.message) when present.
const detail = raw.message ? `: ${raw.message}` : '';
throw new CommandExecutionError(`Pinterest request failed (HTTP ${status})${detail}${hint}`);
}
if (!raw || typeof raw !== 'object' || raw.__malformed) {
throw new CommandExecutionError('Pinterest request returned malformed JSON payload');
}
const resourceResponse = raw.resource_response;
if (!resourceResponse || typeof resourceResponse !== 'object') {
throw new CommandExecutionError('Pinterest request returned malformed API payload');
}
const payload = resourceResponse.data;
const results = Array.isArray(payload)
? payload
: (payload && Array.isArray(payload.results) ? payload.results : []);
return { data: payload, results, bookmark: resourceResponse.bookmark || null };
}
/** POST a /create/ mutation; returns the created resource_response.data. */
export async function pinterestResourceCreate(page, resource, options, sourceUrl) {
const { data } = await pinterestResourceFetch(page, resource, options, sourceUrl, 'create');
return data;
}
/** POST an /update/ mutation; returns the updated resource_response.data. */
export async function pinterestResourceUpdate(page, resource, options, sourceUrl) {
const { data } = await pinterestResourceFetch(page, resource, options, sourceUrl, 'update');
return data;View on GitHub (pinned to 49907e53dc)
Solutions
- Update the CLI/library in case Pinterest changed the response shape (check for newer version)
- Log the raw response in Chrome DevTools Network tab for /resource/ calls and compare shape
- Retry later — sometimes Pinterest returns degraded envelopes under load
- Ensure no bot-detection wall is active (complete any captcha in Chrome)
Defensive patterns
Strategy: fallback
Validate before calling
null
Type guard
null
Try / catch
try { const r = await cmd.board(t); } catch (e) { if (/malformed API payload/.test(e.message)) { console.error('Pinterest response shape changed or degraded — update the CLI or retry later.'); } throw e; } Prevention
- Keep the CLI/library updated for Pinterest API shape changes
- Watch for bot-detection walls and complete captchas in Chrome
- Log unexpected payloads for debugging
- Retry later when Pinterest returns degraded envelopes
When it happens
Trigger: Pinterest changed or degraded the resource API response shape; the endpoint returned an error envelope without resource_response; a captcha/bot-detection JSON body instead of the normal envelope.
Common situations: Pinterest frontend API changes breaking scrapers; response intercepted by bot mitigation; requesting a resource that no longer exists with a changed response shape.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Flomo API returned a malformed memo entry
- no signed url returned for attachment ${id}
- expected array of rows from server, got ${typeof rows} (cont
- Bilibili creator comparison API returned a malformed envelop
- Bilibili creator comparison API returned malformed list data
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/b5ed4d6ca6703148.
Report an issue: GitHub.