jackwener/OpenCLI · error · CommandExecutionError
xiaohongshu creator-note-detail: signed API ${suffix} return
Error message
xiaohongshu creator-note-detail: signed API ${suffix} returned invalid JSON or payload shape What it means
parseCapturedJson throws this CommandExecutionError when the captured response body cannot be JSON.parsed, or the extracted payload fails validateCapturedPayload. It collapses JSON syntax errors and payload-shape validation failures into one message, so the signed endpoint replied 2xx with text that is not the expected JSON envelope/data shape.
Source
Thrown at clis/xiaohongshu/creator-note-detail.js:317
}
function parseCapturedJson(capture, endpoint) {
const suffix = endpoint.suffix;
if (!capture || typeof capture !== 'object') {
throw new CommandExecutionError(`xiaohongshu creator-note-detail: malformed capture for ${suffix}`);
}
if (capture.ok !== true) {
throw new CommandExecutionError(`xiaohongshu creator-note-detail: signed API ${suffix} returned HTTP ${capture.status ?? 'non-2xx'}`);
}
if (typeof capture.body !== 'string') {
throw new CommandExecutionError(`xiaohongshu creator-note-detail: signed API ${suffix} returned a non-text body`);
}
try {
const envelope = JSON.parse(capture.body);
const payload = isPlainObject(envelope) && Object.hasOwn(envelope, 'data') ? envelope.data : envelope;
return validateCapturedPayload(payload, endpoint);
}
catch {
throw new CommandExecutionError(`xiaohongshu creator-note-detail: signed API ${suffix} returned invalid JSON or payload shape`);
}
}
// Capture the dashboard's signed datacenter/note responses on window.__xhsCapture
// since a direct fetch() from page.evaluate bypasses the x-s signing and gets 406.
async function installXhsFetchCaptureHook(page) {
await page.evaluate(`(() => {
const targetPaths = ${JSON.stringify(DETAIL_API_ENDPOINTS.map((endpoint) => endpoint.suffix))};
const shouldCapture = (url) => {
try {
return targetPaths.includes(new URL(String(url), window.location.origin).pathname);
} catch (_) {
return false;
}
};
// Reset the buffer every call so stale captures from a previous run on
// the same tab cannot leak into the current navigation's harvest.
window.__xhsCapture = {};
if (window.__xhsCaptureInstalled) return;View on GitHub (pinned to 49907e53dc)
Solutions
- Re-login to creator.xiaohongshu.com and retry — an HTML login page captured in place of JSON is the most common cause.
- Inspect the raw body (network tab) for the failing endpoint to see whether it is HTML, empty, or changed JSON.
- Retry later if risk control is serving challenge pages; reduce request frequency between runs.
- Update the CLI / report a schema change if Xiaohongshu altered the datacenter/note response envelope.
- Confirm the note actually has detail statistics; a brand-new or deleted note can produce an unexpected shape.
Example fix
// before
const rows = await run('xiaohongshu creator-note-detail', { 'note-id': id });
// after
try {
const rows = await run('xiaohongshu creator-note-detail', { 'note-id': id });
} catch (e) {
if (/invalid JSON or payload shape/.test(e.message)) {
await ensureCreatorLogin(page); // re-open creator.xiaohongshu.com, confirm dashboard loads
return await run('xiaohongshu creator-note-detail', { 'note-id': id });
}
throw e;
} Defensive patterns
Strategy: validation
Validate before calling
// pre-check: dashboard session returns JSON
const probe = await fetch('https://creator.xiaohongshu.com/new/home', { headers: { accept: 'text/html' } });
if (!probe.ok || (await probe.text()).includes('login')) await relogin(); Type guard
function looksLikeEnvelope(x) {
return typeof x === 'object' && x !== null && !Array.isArray(x);
} Try / catch
try {
return await run('xiaohongshu creator-note-detail', { 'note-id': id });
} catch (e) {
if (/invalid JSON or payload shape/.test(e.message)) {
await ensureCreatorLogin();
return await run('xiaohongshu creator-note-detail', { 'note-id': id });
}
throw e;
} Prevention
- Verify login before each run; HTML login pages captured as 2xx are the top cause.
- Keep the CLI updated for Xiaohongshu schema changes.
- Avoid running during risk-control-prone bursts; add delays between commands.
- Check the network tab once if it persists, to see whether the body is HTML, empty, or new-schema JSON.
- Test with notes that already have statistics data.
When it happens
Trigger: The datacenter/note endpoint returns HTML (login redirect page), an empty body, an anti-bot challenge page, or JSON whose shape (envelope.data / expected fields) doesn't match what validateCapturedPayload requires for that endpoint.
Common situations: Session expired mid-run so a 2xx redirect/HTML page was captured; Xiaohongshu changed the API response schema after a dashboard update; risk control served a verification/JSONP/error page; note has no statistics yet so the payload shape differs.
Understand the failure class
Background: "Invalid JSON response" and "Failed to parse response" errors: when an API answers 200 but the body isn't the JSON your library expected — 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
- Flomo API returned a malformed response
- Xiaohongshu 点点 did not accept the query. Check login status
- Xiaohongshu creator profile requires login: ${detail}
- No notes found. Ensure you are logged into creator.xiaohongs
- No notes found. Ensure you are logged into creator.xiaohongs
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/dffcb734d31cd2b4.
Report an issue: GitHub.