jackwener/OpenCLI · error
取消点赞失败: ${errorMessage}
Error message
取消点赞失败: ${errorMessage} What it means
The hupu 'unlike' command wraps its whole operation in a catch block and rethrows any non-CliError failure as `取消点赞失败: <inner message>`. The inner message comes either from postHupuJson (CommandExecutionError/AuthRequiredError are CliError subclasses passed through untouched, so reaching this wrapper means a plain Error) or from the response-shape checks in unlike.js (e.g. `接口错误 code=...`). It signals the cancel-like API call did not complete in an expected way.
Source
Thrown at clis/hupu/unlike.js:73
status: '⚠️ 你还没点赞过',
message: result.msg || ''
}];
}
else if (result.code === 0) {
return [{
status: '⚠️ 操作未执行',
message: result.msg || result.message || ''
}];
}
else {
throw new Error(`接口错误 code=${result.code}: ${result.msg || result.message}`);
}
}
catch (error) {
if (error instanceof CliError)
throw error;
const errorMessage = error instanceof Error ? error.message : String(error);
throw new Error(`取消点赞失败: ${errorMessage}`);
}
},
});
View on GitHub (pinned to 49907e53dc)
Solutions
- Check the inner message after the prefix — it contains the real cause from postHupuJson or the API.
- Log in to Hupu again / refresh cookies, since expired sessions are the most common cause of unexpected API responses.
- Verify tid (9-digit thread id), pid and fid are correct and the reply exists.
- If the inner message is 接口错误 code=..., the API returned an unmapped code — inspect the raw response and update the CLI's response handling.
Example fix
// before
const result = await postHupuJson(page, tid, url, body, 'Unlike Hupu reply');
if (result.code === 1) { /* success */ }
// after — handle unexpected codes explicitly before throwing
const result = await postHupuJson(page, tid, url, body, 'Unlike Hupu reply');
if (result.code === 1) { /* success */ }
else if (result.code === 0) { /* already unlit / no-op message */ }
else { console.error('raw:', JSON.stringify(result)); throw new Error(`接口错误 code=${result.code}: ${result.msg || result.message}`); } Defensive patterns
Strategy: try-catch
Validate before calling
// before invoking: verify required args look sane
if (!/^\d{9}$/.test(String(tid))) throw new Error(`invalid tid: ${tid}`);
if (!pid || !fid) throw new Error('pid and fid are required');
const inner = await postHupuJson(page, tid, url, body, 'Unlike Hupu reply');
if (inner && typeof inner.code !== 'number') throw new Error(`unexpected API shape: ${JSON.stringify(inner).slice(0,200)}`); Type guard
function isApiResult(r) {
return typeof r === 'object' && r !== null && typeof r.code === 'number';
} Try / catch
try {
await hupuUnlike(tid, pid, fid);
} catch (err) {
if (/取消点赞失败:/.test(err.message)) {
const inner = err.message.replace('取消点赞失败: ', '');
if (/log in|401|403/i.test(inner)) return refreshLoginAndRetry();
console.error('unlike failed, inner cause:', inner);
} else throw err;
} Prevention
- Always read the text after '取消点赞失败:' — it contains the actionable root cause.
- Keep the Hupu session logged in; re-login before batch write operations.
- Validate tid/pid/fid arguments against the expected formats before calling.
- Handle code=0 (你还没有点亮过这个回帖) as an expected no-op rather than an error path.
- Log the raw API result (result.code/result.msg) when adding new handling branches.
When it happens
Trigger: Running `hupu unlike <tid> <pid> --fid <fid>` when postHupuJson throws a plain Error (not CliError), or when the cancelLight API returns a code that is neither 1 nor 0, so `throw new Error(接口错误 code=...)` at unlike.js:66 is caught and re-wrapped at line 73.
Common situations: Hupu changes the cancelLight API response contract (new code value), session cookies are stale so the browser POST returns an unexpected payload, a network failure inside page.evaluate produces a fetch error message, or tid/pid/fid arguments are wrong so the API returns an unmapped error code.
Related errors
- --limit must be a positive integer in [1, ${HOT_LIMIT_MAX}],
- ${actionLabel} failed: invalid browser response
- bbs.hupu.com
- linux.do requires an active signed-in browser session
- Please verify your linux.do session is still valid
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/0a930c4a6582e149.
Report an issue: GitHub.