jackwener/OpenCLI · error · CommandExecutionError
Read Hupu mentions failed: ${result.error || 'unknown error'
Error message
Read Hupu mentions failed: ${result.error || 'unknown error'} What it means
CommandExecutionError is thrown when the in-page scrape of the Hupu mentions API reports ok:false for any reason other than 401/403 auth failure. The browser-side code converts non-OK HTTP responses, business error codes (api.code > 1), and any thrown fetch/parse exception into {ok:false, error}, and this line re-raises it host-side. It is a generic wrapper for network, API, or parsing failures during the mentions read.
Source
Thrown at clis/hupu/mentions.js:137
pageStr: nextPageStr
}
};
} catch (error) {
return {
ok: false,
error: error instanceof Error ? error.message : String(error)
};
}
})()
`);
if (!result || typeof result !== 'object') {
throw new CommandExecutionError('Read Hupu mentions failed: invalid browser response');
}
if (result.status === 401 || result.status === 403) {
throw new AuthRequiredError('my.hupu.com', 'Read Hupu mentions failed: please log in to Hupu first');
}
if (!result.ok) {
throw new CommandExecutionError(`Read Hupu mentions failed: ${result.error || 'unknown error'}`);
}
const items = result.data?.items || [];
return items.map((item) => {
const tid = item.tid ? String(item.tid) : '';
const pid = item.pid ? String(item.pid) : '';
return {
time: item.publishTime || '',
username: item.username || '',
thread_title: item.threadTitle || '',
post_content: stripHtml(item.postContent || ''),
quote_content: stripHtml(item.quoteContent || ''),
url: tid ? `https://bbs.hupu.com/${tid}.html` : '',
reply_url: tid && pid ? `https://bbs.hupu.com/${tid}.html?pid=${pid}` : '',
tid,
pid,
topic_id: item.topicId ? String(item.topicId) : '',
msg_type: item.msgType ?? '',
has_next_page: result.data?.hasNextPage ?? false,View on GitHub (pinned to 49907e53dc)
Solutions
- Read the wrapped result.error text to identify the underlying cause (HTTP status vs API msg).
- Retry after a short delay if the error is transient (5xx, network, rate limit).
- Confirm you can load https://my.hupu.com/message in the browser and the API returns data normally.
- If Hupu changed the API/shape, update the endpoint or parsing logic in clis/hupu/mentions.js.
Example fix
// before
const result = await page.evaluate(script); // throws opaque CommandExecutionError
// after: catch and retry transient failures
try {
const result = await page.evaluate(script);
} catch (e) {
if (/HTTP 5|network/i.test(e.message)) await sleep(3000); // then retry
throw e;
} Defensive patterns
Strategy: retry
Validate before calling
// Sanity-check connectivity and params before invoking
if (!(Number.isInteger(limit) && limit >= 1 && limit <= 100)) throw new Error('limit must be 1-100');
if (!(Number.isInteger(maxPages) && maxPages >= 1 && maxPages <= 10)) throw new Error('max_pages must be 1-10');
const res = await fetch('https://my.hupu.com/pcmapi/pc/space/v1/getMentionedRemindList?plate=1', { credentials: 'include' });
if (!res.ok) console.warn('Hupu API currently unhealthy: HTTP', res.status); Type guard
function isBrowserScrapeResult(r) {
return r !== null && typeof r === 'object' && typeof r.ok === 'boolean';
} Try / catch
for (let attempt = 1; attempt <= 3; attempt++) {
try { return await run('hupu mentions', { limit, max_pages }); }
catch (e) {
if (e.name === 'AuthRequiredError') throw e; // do not retry auth
if (attempt === 3) throw e;
await new Promise(r => setTimeout(r, 2000 * attempt)); // backoff for 5xx/network
}
} Prevention
- Inspect result.error in the message to distinguish transient (5xx/network) from permanent (API change) causes.
- Add exponential backoff retries for network/5xx errors only.
- Verify the my.hupu.com pcmapi endpoint still works manually when errors persist.
- Keep limit/max_pages within documented bounds (1-100, 1-10) to avoid parameter-driven failures.
When it happens
Trigger: HTTP != 2xx from getMentionedRemindList (e.g. 5xx); Hupu API business code > 1 (e.g. risk-control or parameter errors); fetch network failure inside the page; non-JSON response body; any exception thrown in the evaluate loop, all surfacing as result.error.
Common situations: Transient Hupu server errors or rate limiting; Hupu changed the private pcmapi endpoint or response shape; page navigation/interruption cancels the fetch; anti-bot checks returning an error body; network outage while the browser ran the request.
Related errors
- Failed to read hupu hot threads: ${message}
- 1point3acres request failed: ${error?.message || error}
- 1point3acres request failed: HTTP ${res.status} ${res.status
- Barchart greeks request failed: HTTP ${data.status}${data.st
- 获取视频分P信息失败: ${payload?.message ?? 'unknown'} (${payload?.cod
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/c2aa90bf9132c2bb.
Report an issue: GitHub.