jackwener/OpenCLI · error
接口错误 code=${result.code}: ${result.msg || result.message}
Error message
接口错误 code=${result.code}: ${result.msg || result.message} What it means
Thrown by the hupu unlike CLI when cancelLight returns a code that is neither 1 (success) nor 0 (handled as benign 'not executed / never liked' cases). Only unexpected business codes (negative values or codes > 1, e.g. risk-control or parameter errors) reach this branch; the outer catch then re-wraps it as '取消点赞失败: ...'.
Source
Thrown at clis/hupu/unlike.js:66
return [{
status: '✅ 取消点赞成功',
message: ''
}];
}
else if (result.code === 0 && result.msg === '你还没有点亮过这个回帖') {
return [{
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 code/msg in the message; correct fid so it matches the thread's board.
- Verify tid and pid refer to an existing reply you have previously liked.
- Re-login to bbs.hupu.com to refresh cookies if the code suggests auth issues.
- If risk-control is suspected, wait and retry later; avoid rapid automated actions.
Example fix
// before: wrong board id $ opencli hupu unlike 631234567 12345678 --fid 999 Error: 取消点赞失败: 接口错误 code=-1: 参数错误 // after: use the correct fid for the thread's board $ opencli hupu unlike 631234567 12345678 --fid 278 ✅ 取消点赞成功
Defensive patterns
Strategy: validation
Validate before calling
// Validate unlike inputs before calling
if (!/^\d{9}$/.test(String(tid))) throw new Error('tid must be a 9-digit thread ID');
if (!String(pid).trim()) throw new Error('pid (reply id) is required');
if (!String(fid).trim()) throw new Error('fid (board id, e.g. 278) is required and must match the thread\'s board'); Type guard
function isUnexpectedApiCode(result) {
return result !== null && typeof result === 'object' && typeof result.code === 'number' && result.code !== 0 && result.code !== 1;
} Try / catch
try {
await run('hupu unlike', { _: [tid, pid], fid });
} catch (e) {
const m = String(e.message).match(/接口错误 code=(\S+): (.*)/);
if (m) {
if (m[2].includes('点亮') || m[2].includes('参数')) console.warn('Skipped:', m[2]); // benign/input issue
else throw e; // unexpected — retry or re-auth
} else throw e;
} Prevention
- Pass the fid that matches the thread's actual board (e.g. 278 for the car section).
- Confirm the target reply was previously liked; unlike on an unliked reply returns code 0 (a warning, not an error).
- Verify tid/pid still refer to an existing reply (deleted replies can yield odd codes).
- Refresh login cookies if codes suggest auth/risk-control issues, and avoid rapid automated unlikes.
When it happens
Trigger: Calling 'hupu unlike <tid> <pid> --fid <fid>' where the API responds with an unexpected code: invalid/mismatched fid, nonexistent tid/pid, account flagged by risk control, or auth rejected with a non-standard code. code===0 outcomes are returned as warnings instead.
Common situations: Passing fid that doesn't match the thread's board; trying to unlike a deleted reply; risk-control/anti-bot rejection; stale cookies causing an unusual error code; Hupu changing the API contract.
Related errors
- 接口错误 code=${result.code}: ${result.msg || result.message}
- 接口错误 code=${result.code}: ${result.msg || result.message}
- Read Hupu mentions failed: ${result.error || 'unknown error'
- 回复失败: ${errorMessage}
- ${probe.detail}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/95c6488b1fca80ee.
Report an issue: GitHub.