jackwener/OpenCLI · error · CommandExecutionError
Failed to parse Jike topic data: ${data.message || 'unknown
Error message
Failed to parse Jike topic data: ${data.message || 'unknown error'} What it means
When the embedded JSON script exists but JSON.parse of its textContent fails, the in-page script returns {reason:'parse-error', message} and the CLI wraps it in CommandExecutionError with the underlying parse message. This indicates the page's data blob is present but not valid JSON in the expected structure.
Source
Thrown at clis/jike/topic.js:61
`);
if (Array.isArray(data)) {
if (data.length === 0) {
throw new EmptyResultError('jike topic', `No posts were returned for topic ${args.id}. Confirm the topic ID and login state.`);
}
return data.slice(0, limit).map((item) => ({
content: item.content ?? '',
author: item.author ?? '',
likes: item.likes ?? 0,
comments: item.comments ?? 0,
time: item.time ?? '',
url: `https://web.okjike.com/originalPost/${item.id ?? ''}`,
}));
}
if (data?.reason === 'missing-data-script') {
throw new CommandExecutionError('Jike topic page did not expose the expected data script');
}
if (data?.reason === 'parse-error') {
throw new CommandExecutionError(`Failed to parse Jike topic data: ${data.message || 'unknown error'}`);
}
throw new CommandExecutionError('Jike topic returned an unreadable payload');
},
});
View on GitHub (pinned to 49907e53dc)
Solutions
- Reload the page and retry — corrupted payloads are often transient.
- Re-login and retry in case the served content differs by auth state.
- Update the CLI/package to match a new Jike data format.
- Capture data.message in the error for the exact JSON.parse failure and inspect the raw script tag in a browser.
Example fix
// before
const data = JSON.parse(el.textContent || '{}');
// after: tolerate partial content and log the snippet
let data;
try {
data = JSON.parse(el.textContent || '{}');
} catch (e) {
console.error('script head:', (el.textContent || '').slice(0, 200));
throw e;
} Defensive patterns
Strategy: retry
Validate before calling
// quick preflight that the script tag holds parseable JSON
const ok = await page.evaluate(() => {
const el = document.querySelector('script[type="application/json"]');
if (!el) return false;
try { JSON.parse(el.textContent || '{}'); return true; } catch { return false; }
});
if (!ok) await page.reload(); Try / catch
try {
return await runCli(['jike', 'topic', id]);
} catch (e) {
if (/Failed to parse Jike topic data/.test(e.message) && attempt < 3) { await sleep(1000); return retry(); }
throw e;
} Prevention
- Reload on first failure — corrupted payloads are often transient.
- Record data.message from the error to pinpoint the JSON.parse cause.
- Update the scraper if Jike changed what goes into the script tag.
When it happens
Trigger: JSON.parse throws inside the evaluate — the script tag contains truncated, HTML-escaped, or non-JSON content (e.g. an error page rendered into the same tag, or an encoding issue).
Common situations: CDN/edge serving a corrupted or partial response; Jike embedding a different payload shape into the same script tag after a front-end update; charset/escaping mismatches in the served HTML.
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
- Failed to parse Jike post data: ${data.message || 'unknown e
- Jike post page did not expose the expected data script
- Jike post returned an unreadable payload
- Jike topic page did not expose the expected data script
- Jike topic returned an unreadable payload
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/cccffd6b6e425c4a.
Report an issue: GitHub.