{"record":{"id":"aecf2037eee9f21b","repo":"jackwener/OpenCLI","slug":"cookie-chrome-weibo","errorCode":null,"errorMessage":"Cookie 已过期！请在当前 Chrome 浏览器中重新登录 Weibo。","messagePattern":"Cookie 已过期！请在当前 Chrome 浏览器中重新登录 Weibo。","errorType":"exception","errorClass":"AuthRequiredError","httpStatus":null,"severity":"error","filePath":"clis/weibo/delete.js","lineNumber":152,"sourceCode":"        try {\n          verifyBody = await verifyResp.json();\n        } catch {\n          return { ok: false, error: 'verify_malformed', msg: 'verify returned non-JSON response', id: idstr };\n        }\n        if (!verifyBody || typeof verifyBody !== 'object') {\n          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__ = {","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/weibo/delete.js#L134-L170","documentation":"clis/weibo/delete.js:152 throws AuthRequiredError with this message when the in-page delete script reports error==='auth', meaning Weibo treated the request as unauthenticated. The command automates weibo.com through the user's current Chrome session, so it has no credentials of its own — it depends entirely on live login cookies. When those cookies are missing or expired, Weibo redirects/rejects and the CLI surfaces this error telling the user to re-login in Chrome.","triggerScenarios":"Running `weibo delete <id|url>` when the Chrome profile's weibo.com session cookie has expired or the user is logged out; result.error from the evaluate() script is exactly 'auth'.","commonSituations":"Chrome cookies expired after Weibo's session timeout (typically days-weeks); user logged out of weibo.com or logged into a different account; running the CLI from a headless/CI environment where the Chrome profile was never logged in; Weibo invalidating sessions after a security prompt or password change.","solutions":["Open weibo.com in the current Chrome browser and log in manually, then retry the command","Verify the Chrome profile the CLI attaches to is the one that is logged in (not a fresh/clean profile)","If login keeps failing, clear weibo.com cookies and log in again, completing any SMS/QR security verification","Avoid changing the account password right before use, which invalidates existing sessions"],"exampleFix":"// before: failing run\n$ opencli weibo delete 51aBcDeFgH\nAuthRequiredError: Cookie 已过期！请在当前 Chrome 浏览器中重新登录 Weibo。\n// after: re-login then retry\n1. chrome -> weibo.com -> log in\n2. $ opencli weibo delete 51aBcDeFgH  // succeeds","handlingStrategy":"try-catch","validationCode":"// best-effort pre-check: cannot inspect Chrome cookies from Node; validate input instead\nif (!id || !/^[A-Za-z0-9]{4,32}$/.test(String(id).trim())) throw new Error('invalid weibo post id');","typeGuard":"function isAuthRequiredError(e) { return e instanceof Error && /重新登录|AuthRequired/i.test(e.message); }","tryCatchPattern":"try {\n  await cli.run('weibo delete', { id });\n} catch (e) {\n  if (isAuthRequiredError(e)) {\n    console.error('Login to weibo.com in Chrome, then retry.');\n    process.exitCode = 2; // distinct auth exit code\n  } else throw e;\n}","preventionTips":["Periodically open weibo.com in Chrome to keep the session alive","Run auth-sensitive commands after confirming manual browsing works","Never run these commands against a headless profile that was never logged in","Watch for AuthRequiredError and stop the batch immediately instead of hammering"],"tags":["auth","cookie-expired","weibo","browser-automation"],"backgroundTag":"auth-cookie-expired","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}