{"record":{"id":"8e9a8dbb7ff19c86","repo":"jackwener/OpenCLI","slug":"pixiv-whoami-failed-probe-detail","errorCode":null,"errorMessage":"Pixiv whoami failed: ${probe.detail}","messagePattern":"Pixiv whoami failed: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/pixiv/auth.js","lineNumber":46,"sourceCode":"      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  },\n});","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/pixiv/auth.js#L28-L64","documentation":"The in-page identity probe is wrapped in try/catch; any exception thrown while parsing global-data, fetching /ajax/user/extra, or reading cookies is converted to kind='exception' with the error message. verifyPixivIdentity then rethrows it as this CommandExecutionError. This means the probe script itself crashed rather than pixiv returning a structured auth/http answer.","triggerScenarios":"The probe's async IIFE throws: r.json() fails on a non-JSON (HTML/CDN error) response, a CSP/security change blocks fetch or document.cookie access, or an unexpected DOM/network exception occurs during page.evaluate.","commonSituations":"Bot-protection page serving HTML where JSON was expected; browser extension or strict cookie policy hiding document.cookie; pixiv JS/DOM changes breaking the probe; navigation interrupting the evaluate.","solutions":["Read the embedded detail in the message to see the underlying exception and fix accordingly.","Reload pixiv.net and retry — the page may have been mid-navigation or served an interstitial.","Retry after clearing bot-protection (solve any challenge) in the browser profile.","Update the probe if pixiv changed its page structure or cookie access rules."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await pixivWhoAmI();\n} catch (err) {\n  if (String(err.message).startsWith('Pixiv whoami failed:')) {\n    // log the inner detail, reload pixiv.net, retry once\n    await page.goto('https://www.pixiv.net/');\n    await pixivWhoAmI();\n  } else throw err;\n}","preventionTips":["Keep the browser parked on a fully loaded pixiv.net page before probing.","Disable extensions/strict cookie policies in the automation profile.","Log the inner detail from the message to distinguish JSON-parse vs DOM failures.","Retry once after a page reload — many causes are transient interstitials."],"tags":["pixiv","probe","javascript","parsing"],"backgroundTag":"unexpected-runtime-exception","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}