{"record":{"id":"95c6488b1fca80ee","repo":"jackwener/OpenCLI","slug":"code-result-code-result-msg-result-m-95c648","errorCode":null,"errorMessage":"接口错误 code=${result.code}: ${result.msg || result.message}","messagePattern":"接口错误 code=(.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"clis/hupu/unlike.js","lineNumber":66,"sourceCode":"                return [{\n                        status: '✅ 取消点赞成功',\n                        message: ''\n                    }];\n            }\n            else if (result.code === 0 && result.msg === '你还没有点亮过这个回帖') {\n                return [{\n                        status: '⚠️ 你还没点赞过',\n                        message: result.msg || ''\n                    }];\n            }\n            else if (result.code === 0) {\n                return [{\n                        status: '⚠️ 操作未执行',\n                        message: result.msg || result.message || ''\n                    }];\n            }\n            else {\n                throw new Error(`接口错误 code=${result.code}: ${result.msg || result.message}`);\n            }\n        }\n        catch (error) {\n            if (error instanceof CliError)\n                throw error;\n            const errorMessage = error instanceof Error ? error.message : String(error);\n            throw new Error(`取消点赞失败: ${errorMessage}`);\n        }\n    },\n});\n","sourceCodeStart":48,"sourceCodeEnd":77,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/hupu/unlike.js#L48-L77","documentation":"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 '取消点赞失败: ...'.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before: wrong board id\n$ opencli hupu unlike 631234567 12345678 --fid 999\nError: 取消点赞失败: 接口错误 code=-1: 参数错误\n\n// after: use the correct fid for the thread's board\n$ opencli hupu unlike 631234567 12345678 --fid 278\n✅ 取消点赞成功","handlingStrategy":"validation","validationCode":"// Validate unlike inputs before calling\nif (!/^\\d{9}$/.test(String(tid))) throw new Error('tid must be a 9-digit thread ID');\nif (!String(pid).trim()) throw new Error('pid (reply id) is required');\nif (!String(fid).trim()) throw new Error('fid (board id, e.g. 278) is required and must match the thread\\'s board');","typeGuard":"function isUnexpectedApiCode(result) {\n  return result !== null && typeof result === 'object' && typeof result.code === 'number' && result.code !== 0 && result.code !== 1;\n}","tryCatchPattern":"try {\n  await run('hupu unlike', { _: [tid, pid], fid });\n} catch (e) {\n  const m = String(e.message).match(/接口错误 code=(\\S+): (.*)/);\n  if (m) {\n    if (m[2].includes('点亮') || m[2].includes('参数')) console.warn('Skipped:', m[2]); // benign/input issue\n    else throw e; // unexpected — retry or re-auth\n  } else throw e;\n}","preventionTips":["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."],"tags":["hupu","api-error","write-operation","unexpected-response"],"backgroundTag":"api-business-error-code","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}