{"record":{"id":"1c8569503ce5ba7b","repo":"jackwener/OpenCLI","slug":"code-result-code-result-msg-result-m-1c8569","errorCode":null,"errorMessage":"接口错误 code=${result.code}: ${result.msg || result.message}","messagePattern":"接口错误 code=(.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"clis/hupu/reply.js","lineNumber":62,"sourceCode":"            content,\n            shumeiId: '',\n            deviceid: '',\n            tid\n        };\n        // 如果有引用回复ID，添加到请求体\n        if (quote_id) {\n            body.quoteId = quote_id;\n        }\n        try {\n            const result = await postHupuJson(page, tid, url, body, 'Reply to Hupu thread', 'reply');\n            if (result.code === 1) {\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":44,"sourceCodeEnd":73,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/hupu/reply.js#L44-L73","documentation":"Thrown by the hupu reply CLI when postHupuJson returns a response whose code is not 1 (Hupu's success code) for the createReply API. It is a plain Error carrying the API's business code and message (result.msg || result.message). After this throw, the outer catch re-wraps it as '回复失败: 接口错误 code=...'.","triggerScenarios":"Calling 'hupu reply <tid> <text> --topic_id <id>' when Hupu's createReply rejects the request: wrong/nonexistent tid or topic_id, content blocked by moderation/keyword filters, not logged in or cookie invalid, duplicate reply, or account restricted from posting.","commonSituations":"Passing a topic_id that does not match the thread's board; replying to a locked or deleted thread; reply text hitting Hupu content filters; posting too frequently and being rate-limited; expired login cookies.","solutions":["Read code and msg in the message: fix the identified issue (wrong tid/topic_id, banned content, permissions).","Verify tid is a valid 9-digit thread ID and topic_id matches the thread's board (e.g. 502 for basketball news).","Re-authenticate: ensure the browser session is logged in to bbs.hupu.com with valid cookies.","If content was rejected, reword the reply to avoid Hupu keyword/moderation filters.","Slow down if rate-limited; wait before retrying."],"exampleFix":"// before: failing call with mismatched board\n$ opencli hupu reply 631234567 \" nice\" --topic_id 999\nError: 回复失败: 接口错误 code=40002: 板块不匹配\n\n// after: use the thread's real board id\n$ opencli hupu reply 631234567 \"nice\" --topic_id 502\n✅ 回复成功","handlingStrategy":"validation","validationCode":"// Validate inputs before calling hupu reply\nif (!/^\\d{9}$/.test(String(tid))) throw new Error('tid must be a 9-digit thread ID');\nif (!String(topic_id).trim()) throw new Error('topic_id (board id, e.g. 502) is required and must match the thread\\'s board');\nif (!String(text).trim()) throw new Error('reply text must not be empty');\n// Optionally pre-check thread exists:\nconst page = await fetch(`https://bbs.hupu.com/${tid}.html`);\nif (!page.ok) throw new Error(`Thread ${tid} not accessible (HTTP ${page.status}) — cannot reply`);","typeGuard":"function isApiSuccess(result) {\n  return result !== null && typeof result === 'object' && result.code === 1;\n}","tryCatchPattern":"try {\n  await run('hupu reply', { _: [tid, text], topic_id });\n} catch (e) {\n  const m = String(e.message).match(/接口错误 code=(\\S+): (.*)/);\n  if (m) console.error(`Hupu rejected reply (code ${m[1]}): ${m[2]} — check tid/topic_id, login, and content policy`);\n  else throw e;\n}","preventionTips":["Always pass the correct topic_id matching the thread's board (e.g. 502 for basketball news).","Validate tid format (9 digits) before calling.","Ensure the browser session is logged in to bbs.hupu.com before write operations.","Avoid keyword-triggering or duplicate content; Hupu moderation rejects it with a business code.","Rate-limit your replies to avoid risk-control rejections."],"tags":["hupu","api-error","write-operation","moderation"],"backgroundTag":"api-business-error-code","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}