{"record":{"id":"36a00b63706dd7e9","repo":"jackwener/OpenCLI","slug":"unexpected-pixiv-probe-json-stringify-probe","errorCode":null,"errorMessage":"Unexpected Pixiv probe: ${JSON.stringify(probe)}","messagePattern":"Unexpected Pixiv probe: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/pixiv/auth.js","lineNumber":47,"sourceCode":"        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});\n","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/pixiv/auth.js#L29-L65","documentation":"Final guard in verifyPixivIdentity: after excluding kinds auth/http/exception, the probe must have ok=true. If it doesn't (probe null, an unrecognized kind, or an object lacking ok), this CommandExecutionError is thrown with the whole probe JSON-serialized. It indicates the probe returned an unexpected shape — usually a bug or an unhandled pixiv response variant.","triggerScenarios":"page.evaluate returns null/undefined (page navigated mid-probe or evaluation failed silently), or the probe returns an object that is neither a known kind nor {ok:true,...} — i.e. none of the earlier branches matched.","commonSituations":"Page navigated or closed during the evaluate so the result was lost; pixiv served a completely different page variant; a CLI/probe version mismatch after a refactor added a new probe result kind the thrower doesn't know.","solutions":["Inspect the JSON payload in the message to see what the probe actually returned.","Retry — if the page navigated mid-probe, a fresh run on a stable pixiv.net page should work.","Ensure the browser stays on pixiv.net (no redirects/navigation) while verification runs.","Update the CLI/probe if the message reveals a new probe result shape that isn't handled."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function isKnownProbeResult(probe) {\n  return !!probe && (probe.ok === true\n    || probe.kind === 'auth' || probe.kind === 'http'\n    || probe.kind === 'exception');\n}","tryCatchPattern":"try {\n  await pixivWhoAmI();\n} catch (err) {\n  if (String(err.message).startsWith('Unexpected Pixiv probe:')) {\n    const probe = JSON.parse(String(err.message).slice('Unexpected Pixiv probe:'.length));\n    // inspect probe shape, report bug or handle new kind\n  } else throw err;\n}","preventionTips":["Prevent navigation away from pixiv.net while identity verification runs.","Keep the CLI and probe script versions in sync; update when probe result kinds change.","Always parse and log the embedded probe JSON when this error occurs to spot new variants early."],"tags":["pixiv","probe","unexpected-response"],"backgroundTag":"unexpected-api-response-shape","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}