{"record":{"id":"0a930c4a6582e149","repo":"jackwener/OpenCLI","slug":"errormessage-0a930c","errorCode":null,"errorMessage":"取消点赞失败: ${errorMessage}","messagePattern":"取消点赞失败: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"clis/hupu/unlike.js","lineNumber":73,"sourceCode":"                        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":55,"sourceCodeEnd":77,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/hupu/unlike.js#L55-L77","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nconst result = await postHupuJson(page, tid, url, body, 'Unlike Hupu reply');\nif (result.code === 1) { /* success */ }\n// after — handle unexpected codes explicitly before throwing\nconst result = await postHupuJson(page, tid, url, body, 'Unlike Hupu reply');\nif (result.code === 1) { /* success */ }\nelse if (result.code === 0) { /* already unlit / no-op message */ }\nelse { console.error('raw:', JSON.stringify(result)); throw new Error(`接口错误 code=${result.code}: ${result.msg || result.message}`); }","handlingStrategy":"try-catch","validationCode":"// before invoking: verify required args look sane\nif (!/^\\d{9}$/.test(String(tid))) throw new Error(`invalid tid: ${tid}`);\nif (!pid || !fid) throw new Error('pid and fid are required');\nconst inner = await postHupuJson(page, tid, url, body, 'Unlike Hupu reply');\nif (inner && typeof inner.code !== 'number') throw new Error(`unexpected API shape: ${JSON.stringify(inner).slice(0,200)}`);","typeGuard":"function isApiResult(r) {\n  return typeof r === 'object' && r !== null && typeof r.code === 'number';\n}","tryCatchPattern":"try {\n  await hupuUnlike(tid, pid, fid);\n} catch (err) {\n  if (/取消点赞失败:/.test(err.message)) {\n    const inner = err.message.replace('取消点赞失败: ', '');\n    if (/log in|401|403/i.test(inner)) return refreshLoginAndRetry();\n    console.error('unlike failed, inner cause:', inner);\n  } else throw err;\n}","preventionTips":["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."],"tags":["hupu","http-api","authentication","cli"],"backgroundTag":"upstream-api-unexpected-response","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}