{"record":{"id":"10c29f56e5c17ffe","repo":"jackwener/OpenCLI","slug":"http-result-httpstatus-from-ajax-profile-info","errorCode":null,"errorMessage":"HTTP ${result.httpStatus} from /ajax/profile/info","messagePattern":"HTTP (.+?) from /ajax/profile/info","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/weibo/auth.js","lineNumber":48,"sourceCode":"      return { kind: 'exception', detail: String(e && e.message || e) };\n    }\n  })()`;\n}\n\nasync function verifyWeiboIdentity(page) {\n  if (!await hasWeiboSessionCookie(page)) {\n    throw new AuthRequiredError('weibo.com', 'Weibo SUB / SUBP cookies missing');\n  }\n  await page.goto('https://weibo.com/');\n  await page.wait(3);\n  // getSelfUid throws AuthRequiredError when no logged-in uid can be resolved.\n  const uid = await getSelfUid(page);\n  if (typeof uid !== 'string' || !uid.trim()) {\n    throw new CommandExecutionError('Weibo uid resolver returned a malformed uid');\n  }\n  const result = unwrapEvaluateResult(await page.evaluate(buildWeiboIdentityProbe(uid)));\n  if (result?.kind === 'auth') throw new AuthRequiredError('weibo.com', result.detail);\n  if (result?.kind === 'http') throw new CommandExecutionError(`HTTP ${result.httpStatus} from /ajax/profile/info`);\n  if (result?.kind === 'exception') throw new CommandExecutionError(`Weibo whoami failed: ${result.detail}`);\n  if (!result || Array.isArray(result) || typeof result !== 'object') {\n    throw new CommandExecutionError('Weibo whoami returned malformed probe payload');\n  }\n  if (!result?.ok) throw new CommandExecutionError(`Unexpected Weibo probe: ${JSON.stringify(result)}`);\n  if (!result.user_id) throw new CommandExecutionError('Weibo whoami returned no user id');\n  return { user_id: result.user_id, screen_name: result.screen_name, profile_url: result.profile_url };\n}\n\nregisterSiteAuthCommands({\n  site: 'weibo',\n  domain: 'weibo.com',\n  loginUrl: 'https://weibo.com/login',\n  columns: ['user_id', 'screen_name', 'profile_url'],\n  quickCheck: hasWeiboSessionCookie,\n  verify: verifyWeiboIdentity,\n  poll: async (page) => {\n    if (!await hasWeiboSessionCookie(page)) {","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/weibo/auth.js#L30-L66","documentation":"When the identity probe's fetch of weibo.com /ajax/profile/info returns a non-success HTTP status, the code throws CommandExecutionError(`HTTP ${result.httpStatus} from /ajax/profile/info`). This indicates a transport-level problem (not an auth payload) when validating the logged-in identity.","triggerScenarios":"result.kind === 'http' from the probe: /ajax/profile/info responded 4xx/5xx, e.g. 403 from anti-scraping, 429 rate limit, 5xx server error.","commonSituations":"Weibo rate-limiting rapid automated probes; anti-crawler WAF returning 403/418; transient server 5xx; missing referer/headers on the in-page fetch after a site update.","solutions":["Retry after a delay — 429/5xx are often transient","Check the status code: 403 suggests WAF/anti-bot, 429 suggests rate limiting — slow down request frequency","Ensure the probe fetch includes proper headers (referer, xsrf token) matching current site requirements","Verify the endpoint path /ajax/profile/info is still correct; update if Weibo changed the API","Fall back to an alternate identity source (e.g. page DOM whoami) if the API keeps failing"],"exampleFix":"// before\nif (result?.kind === 'http') throw new CommandExecutionError(`HTTP ${result.httpStatus} from /ajax/profile/info`);\n// after\nif (result?.kind === 'http') {\n  if (result.httpStatus === 429 || result.httpStatus >= 500) {\n    await page.wait(5);\n    result = unwrapEvaluateResult(await page.evaluate(buildWeiboIdentityProbe(uid)));\n  }\n  if (result?.kind === 'http') throw new CommandExecutionError(`HTTP ${result.httpStatus} from /ajax/profile/info`);\n}","handlingStrategy":"retry","validationCode":"// pre-flight status check\nconst status = await page.evaluate(() => fetch('/ajax/profile/info', { credentials: 'include' }).then(r => r.status));\nif (status !== 200) console.warn(`/ajax/profile/info returned ${status} — expect retries or failure`);","typeGuard":null,"tryCatchPattern":"try {\n  await verifyWeiboIdentity(page);\n} catch (e) {\n  const m = /HTTP (\\d+) from \\/ajax\\/profile\\/info/.exec(e.message);\n  if (m) {\n    const code = Number(m[1]);\n    if (code === 429 || code >= 500) {\n      await sleep(5000); // then retry once\n    } else {\n      console.error(`Profile API returned ${code}; check headers/endpoint/anti-bot measures.`);\n    }\n  } else throw e;\n}","preventionTips":["Throttle request frequency to avoid 429s","Send referer/anti-CSRF headers matching current site expectations","Add backoff retries for 429/5xx responses","Fall back to DOM-based identity extraction if the API endpoint changes or blocks"],"tags":["http","weibo","rate-limit"],"backgroundTag":"http-error-from-profile-api","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}