{"record":{"id":"e92b13a970043dda","repo":"jackwener/OpenCLI","slug":"unexpected-chaoxing-probe-json-stringify-probe","errorCode":null,"errorMessage":"Unexpected Chaoxing probe: ${JSON.stringify(probe)}","messagePattern":"Unexpected Chaoxing probe: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/chaoxing/auth.js","lineNumber":37,"sourceCode":"      }\n      const userIdCookie = (document.cookie.split('; ').find(c => /^(_uid|UID)=/.test(c)) || '').split('=')[1] || '';\n      let userName = '';\n      const unameCookie = (document.cookie.split('; ').find(c => /^uname=/.test(c)) || '').split('=')[1] || '';\n      if (unameCookie) {\n        try { userName = decodeURIComponent(unameCookie); } catch { userName = unameCookie; }\n      }\n      if (!userName) {\n        const el = document.querySelector('.userTitle, .myInfo, .user-name, [class*=userName]');\n        userName = (el?.innerText || '').trim();\n      }\n      if (!userIdCookie && !userName) {\n        return { kind: 'auth', detail: 'Chaoxing i.chaoxing.com no user identity surface — anonymous' };\n      }\n      return { ok: true, user_id: userIdCookie, name: userName };\n    })()\n  `);\n  if (probe?.kind === 'auth') throw new AuthRequiredError('chaoxing.com', probe.detail);\n  if (!probe?.ok) throw new CommandExecutionError(`Unexpected Chaoxing probe: ${JSON.stringify(probe)}`);\n  return { user_id: probe.user_id, name: probe.name };\n}\n\nregisterSiteAuthCommands({\n  site: 'chaoxing',\n  domain: 'chaoxing.com',\n  loginUrl: 'https://passport2.chaoxing.com/login?fid=&newversion=true&refer=https%3A%2F%2Fi.chaoxing.com',\n  columns: ['user_id', 'name'],\n  quickCheck: hasChaoxingSessionCookie,\n  verify: verifyChaoxingIdentity,\n  poll: async (page) => {\n    if (!await hasChaoxingSessionCookie(page)) {\n      throw new AuthRequiredError('chaoxing.com', 'Waiting for Chaoxing session cookies');\n    }\n    return verifyChaoxingIdentity(page);\n  },\n});\n","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/chaoxing/auth.js#L19-L55","documentation":"verifyChaoxingIdentity expects the in-page probe to return either kind:'auth' or ok:true. Any other shape (undefined probe, unexpected object, page script error swallowed into a malformed result) triggers this CommandExecutionError containing the JSON of the probe. It signals the site returned a state the library doesn't recognize — a probe/parse bug or an unexpected page variant, not necessarily an auth problem.","triggerScenarios":"The page.evaluate probe throws or returns undefined/null (navigation interrupted, page landed on an unexpected intermediate page, JS error in the probe), or returns an object with neither kind='auth' nor ok=true.","commonSituations":"Chaoxing deployed a new i.chaoxing.com layout breaking the probe's DOM/cookie reads; page.goto raced with a redirect so evaluate ran on about:blank; page.wait(3) too short for slow networks.","solutions":["Inspect the JSON in the message — it shows exactly what the probe returned","Increase the wait/retry after page.goto so evaluation runs on the fully loaded i.chaoxing.com page","Re-login and retry to rule out an intermediate redirect page","Update the probe script if Chaoxing changed the identity surface (cookie names/DOM)","If probe is null/undefined, wrap evaluate in try/catch and rethrow a clearer error"],"exampleFix":"// before\nconst probe = await page.evaluate(`...`);\nif (!probe?.ok) throw new CommandExecutionError(`Unexpected Chaoxing probe: ${JSON.stringify(probe)}`);\n// after\nlet probe;\ntry { probe = await page.evaluate(`...`); }\ncatch (e) { throw new CommandExecutionError(`Chaoxing probe evaluate failed: ${e.message}`); }\nif (!probe) { await page.wait(3); probe = await page.evaluate(`...`); } // retry once after load","handlingStrategy":"try-catch","validationCode":"await page.goto('https://i.chaoxing.com/', { waitUntil: 'domcontentloaded' });\nif (!page.url().includes('i.chaoxing.com')) throw new Error('Unexpected redirect: ' + page.url());","typeGuard":"function isProbeResult(p) { return !!p && typeof p === 'object' && ('ok' in p || 'kind' in p); }","tryCatchPattern":"let probe;\ntry { probe = await whoami(page); }\ncatch (e) {\n  if (e instanceof CommandExecutionError && e.message.startsWith('Unexpected Chaoxing probe')) {\n    await page.wait(3); return whoami(page); // retry after full load\n  }\n  throw e;\n}","preventionTips":["Wait for the page to fully load before running the in-page probe","Verify the URL is i.chaoxing.com (not a redirect target) before evaluating","Run with the latest library version so probe scripts match current Chaoxing pages","If it recurs, dump the page HTML at failure to identify the new layout and update the probe"],"tags":["chaoxing","probe","unexpected-response","parsing"],"backgroundTag":"unexpected-response-shape","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}