{"record":{"id":"0051a1b8a4874b11","repo":"jackwener/OpenCLI","slug":"weibo-delete-http-result-status","errorCode":null,"errorMessage":"weibo delete: HTTP ${result.status}","messagePattern":"weibo delete: HTTP (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/weibo/delete.js","lineNumber":158,"sourceCode":"          return { ok: false, error: 'verify_malformed', msg: 'verify returned malformed response', id: idstr };\n        }\n        if (String(verifyBody.idstr || '') === idstr) {\n          return { ok: false, error: 'still_exists', id: idstr, mblogid: verifyBody.mblogid || mblogid };\n        }\n        if (!verifyBody.idstr || verifyBody.ok === 0) {\n          return { ok: true, id: idstr, mblogid };\n        }\n        return { ok: false, error: 'verify_mismatch', msg: 'verify returned a different post id', id: idstr };\n      })()\n    `)), 'weibo delete');\n        if (result.error === 'auth') {\n            throw new AuthRequiredError('weibo.com', 'Cookie 已过期！请在当前 Chrome 浏览器中重新登录 Weibo。');\n        }\n        if (result.error === 'not_found') {\n            throw new EmptyResultError('weibo delete', `Post not found for id \"${String(result.input ?? raw)}\". Verify the post still exists and belongs to the logged-in account.`);\n        }\n        if (result.error === 'show_http' || result.error === 'destroy_http' || result.error === 'verify_http') {\n            throw new CommandExecutionError(`weibo delete: HTTP ${result.status}`);\n        }\n        if (result.error === 'api' || result.error === 'verify_malformed' || result.error === 'verify_mismatch' || result.error === 'still_exists') {\n            throw new CommandExecutionError(`weibo delete: ${String(result.msg ?? result.error)}`);\n        }\n        if (!result.ok) {\n            throw new CommandExecutionError('weibo delete returned an unexpected response');\n        }\n        return [{ status: 'deleted', id: String(result.id ?? ''), mblogid: String(result.mblogid ?? '') }];\n    },\n});\n\nexport const __test__ = {\n    normalizePostId,\n};\n","sourceCodeStart":140,"sourceCodeEnd":173,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/weibo/delete.js#L140-L173","documentation":"clis/weibo/delete.js:158 throws CommandExecutionError(`weibo delete: HTTP ${result.status}`) when any of the underlying page fetches (show, destroy, or verify) returned a non-OK HTTP status (error==='show_http'|'destroy_http'|'verify_http'). It reports which stage failed only via the numeric status, keeping auth and not_found as separate, more specific errors.","triggerScenarios":"The in-page fetch to weibo.com's /aj/mblog/del, /ajax/statuses/show, or the verify step returned 4xx/5xx — e.g. 403 risk-control rejection, 418/429 rate limiting, 404 on show, or 5xx server error.","commonSituations":"Deleting many posts in a loop triggers Weibo rate limiting/risk control (403/429); Weibo API surface changed and an endpoint now returns 404; transient 5xx during Weibo incidents; stale CSRF tokens after long-idle sessions.","solutions":["Check result.status in the error: for 403/429 slow down, add delays between deletes, and retry after minutes","Refresh the weibo.com session in Chrome (reload the page, confirm you can delete manually) to pick up fresh tokens","For 404 on show, verify the post id — the post may be gone (see the not_found path)","For persistent 5xx, retry later; check if Weibo changed its endpoints and update the CLI"],"exampleFix":"// before: hammering the API in a loop\nfor (const id of ids) await cli.run('weibo delete', { id });\n// after: throttle + status-aware retry\nfor (const id of ids) {\n  try { await cli.run('weibo delete', { id }); }\n  catch (e) {\n    if (/HTTP (403|429)/.test(e.message)) { await sleep(60000); continue; }\n    throw e;\n  }\n  await sleep(3000);\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":"function isHttpDeleteError(e) { return e instanceof Error && /weibo delete: HTTP \\d+/.test(e.message); }\nfunction httpStatus(e) { const m = /HTTP (\\d+)/.exec(e.message); return m ? Number(m[1]) : 0; }","tryCatchPattern":"const RETRYABLE = new Set([403, 418, 429, 500, 502, 503, 504]);\nfor (let attempt = 0; attempt < 3; attempt++) {\n  try { return await cli.run('weibo delete', { id }); }\n  catch (e) {\n    if (isHttpDeleteError(e) && RETRYABLE.has(httpStatus(e))) { await new Promise(r => setTimeout(r, 15000 * (attempt + 1))); continue; }\n    throw e;\n  }\n}","preventionTips":["Throttle deletes (a few seconds between calls) to avoid risk control","Do not run large delete batches unattended without backoff","Refresh the weibo.com tab periodically so tokens stay fresh","Log the HTTP status from the message to distinguish rate limits from bugs"],"tags":["http","weibo","rate-limit","network"],"backgroundTag":"http-error-response","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}