{"record":{"id":"3c156b996f325dfc","repo":"jackwener/OpenCLI","slug":"http-probe-httpstatus-from-pixiv-ajax","errorCode":null,"errorMessage":"HTTP ${probe.httpStatus} from Pixiv ajax","messagePattern":"HTTP (.+?) from Pixiv ajax","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/pixiv/auth.js","lineNumber":45,"sourceCode":"      const r = await fetch('/ajax/user/extra', { credentials: 'include', headers: { Accept: 'application/json' } });\n      if (r.status === 401 || r.status === 403) {\n        return { kind: 'auth', detail: 'Pixiv /ajax/user/extra HTTP ' + r.status };\n      }\n      if (!r.ok) return { kind: 'http', httpStatus: r.status };\n      const d = await r.json();\n      if (d?.error) return { kind: 'auth', detail: 'Pixiv /ajax/user/extra error=true — anonymous' };\n      const phpSess = (document.cookie.split('; ').find(c => c.startsWith('PHPSESSID=')) || '').split('=')[1] || '';\n      const uid = phpSess.split('_')[0] || '';\n      if (!uid) {\n        return { kind: 'auth', detail: 'Pixiv PHPSESSID prefix unparseable' };\n      }\n      return { ok: true, user_id: uid, name: '' };\n    } catch (e) {\n      return { kind: 'exception', detail: String(e && e.message || e) };\n    }\n  })()`);\n  if (probe?.kind === 'auth') throw new AuthRequiredError('pixiv.net', probe.detail);\n  if (probe?.kind === 'http') throw new CommandExecutionError(`HTTP ${probe.httpStatus} from Pixiv ajax`);\n  if (probe?.kind === 'exception') throw new CommandExecutionError(`Pixiv whoami failed: ${probe.detail}`);\n  if (!probe?.ok) throw new CommandExecutionError(`Unexpected Pixiv probe: ${JSON.stringify(probe)}`);\n  return { user_id: probe.user_id, name: probe.name };\n}\n\nregisterSiteAuthCommands({\n  site: 'pixiv',\n  domain: 'pixiv.net',\n  loginUrl: 'https://accounts.pixiv.net/login',\n  columns: ['user_id', 'name'],\n  quickCheck: hasPixivSessionCookie,\n  verify: verifyPixivIdentity,\n  poll: async (page) => {\n    if (!await hasPixivSessionCookie(page)) {\n      throw new AuthRequiredError('pixiv.net', 'Waiting for Pixiv PHPSESSID cookie');\n    }\n    return verifyPixivIdentity(page);\n  },","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/pixiv/auth.js#L27-L63","documentation":"The in-page identity probe calls /ajax/user/extra with credentials included. When that endpoint returns a non-OK, non-401/403 status, the probe reports kind='http' and verifyPixivIdentity throws this CommandExecutionError with the HTTP status — the request reached pixiv but failed at the HTTP layer.","triggerScenarios":"Pixiv /ajax/user/extra returns 429 (rate limit), 5xx server error, or other non-2xx/non-401/403 status during verifyPixivIdentity's whoami probe.","commonSituations":"Rate limiting after running many pixiv commands in a row; pixiv server-side incident/maintenance window; corporate proxy or bot-protection (e.g. a challenge page) intercepting the ajax call; transient network flake.","solutions":["Wait and retry — especially if status was 429 or 5xx.","Check pixiv status/maintenance announcements if errors persist.","Ensure the request originates from a normal logged-in pixiv.net page context (no proxy/bot-block interference).","Slow down scripted pixiv command loops to avoid rate limits."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await pixivWhoAmI();\n} catch (err) {\n  const m = String(err.message).match(/^HTTP (\\d+) from Pixiv ajax$/);\n  if (m && (m[1] === '429' || m[1].startsWith('5'))) {\n    await delay(30_000);\n    return pixivWhoAmI(); // bounded retry with backoff\n  } else throw err;\n}","preventionTips":["Throttle scripted pixiv commands to avoid 429 rate limits.","Add exponential backoff around pixiv whoami calls.","Watch pixiv maintenance/status channels before large batch runs."],"tags":["pixiv","http","network","rate-limit"],"backgroundTag":"http-5xx","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}