{"record":{"id":"a395778535a4e012","repo":"jackwener/OpenCLI","slug":"weibo-com","errorCode":null,"errorMessage":"weibo.com","messagePattern":"weibo\\.com","errorType":"exception","errorClass":"AuthRequiredError","httpStatus":null,"severity":"error","filePath":"clis/weibo/user-posts.js","lineNumber":68,"sourceCode":"}\n\nfunction dateToTimestamp(date) {\n    return Math.floor(new Date(`${date}T00:00:00+08:00`).getTime() / 1000);\n}\n\nfunction validateRange(start, end) {\n    if (start && end && dateToTimestamp(start) > dateToTimestamp(end)) {\n        throw new ArgumentError('weibo user-posts start must be <= end');\n    }\n}\n\nfunction mapError(error) {\n    const message = String(error ?? '').trim();\n    if (!message) {\n        throw new CommandExecutionError('weibo user-posts failed without an error message');\n    }\n    if (/login|cookie|登录|auth|forbidden|permission|权限|unauthorized/i.test(message)) {\n        throw new AuthRequiredError('weibo.com', message);\n    }\n    throw new CommandExecutionError(message);\n}\n\nexport const testInternals = {\n    readRequiredId,\n    readLimit,\n    readDate,\n    dateToTimestamp,\n};\n\ncli({\n    site: 'weibo',\n    name: 'user-posts',\n    access: 'read',\n    description: 'List Weibo posts from a user, optionally filtered by date range',\n    domain: 'weibo.com',\n    strategy: Strategy.COOKIE,","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/weibo/user-posts.js#L50-L86","documentation":"When mapError() detects auth-related keywords in the underlying error message (login, cookie, 登录, auth, forbidden, permission, 权限, unauthorized), it classifies the failure as an authentication problem for weibo.com and throws AuthRequiredError('weibo.com', message). The message shown is 'weibo.com' — the site that requires valid credentials.","triggerScenarios":"Scraping while not logged in, an expired/invalid weibo.com session cookie, or the page returning a forbidden/permission response during extraction.","commonSituations":"Cookie configuration missing or stale, cookies expired after Weibo rotates the session, running from an IP/region with stricter login enforcement, or Weibo changing its login wall behavior.","solutions":["Log in to weibo.com and export/refresh the cookies used by the CLI.","Verify the cookie file/env configuration the command reads points to the current session's cookies.","Re-run after refreshing; if it persists, check for IP-based blocking or login-wall changes.","Confirm you are logged into the account whose posts you are querying."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"import { existsSync, statSync } from 'node:fs';\nif (!existsSync(cookiePath) || Date.now() - statSync(cookiePath).mtimeMs > 7 * 864e5) {\n  throw new Error('weibo cookies missing or stale; re-export before running');\n}","typeGuard":"function isAuthRequiredError(e) {\n  return e && e.name === 'AuthRequiredError';\n}","tryCatchPattern":"try {\n  await runUserPosts(opts);\n} catch (err) {\n  if (err instanceof AuthRequiredError) {\n    await refreshWeiboCookies(); // re-login and re-export cookies\n    return runUserPosts(opts);\n  }\n  throw err;\n}","preventionTips":["Keep weibo.com session cookies fresh; re-export regularly.","Log in to the account you query before running batch jobs.","Watch for Weibo login-wall/anti-bot changes after long idle periods."],"tags":["authentication","weibo","cookies"],"backgroundTag":"auth-required","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}