{"record":{"id":"64b60a099021f350","repo":"jackwener/OpenCLI","slug":"unexpected-boss-probe-json-stringify-probe","errorCode":null,"errorMessage":"Unexpected Boss probe: ${JSON.stringify(probe)}","messagePattern":"Unexpected Boss probe: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/boss/auth.js","lineNumber":33,"sourceCode":"    throw new AuthRequiredError('zhipin.com', 'Boss wt2 / t cookies missing');\n  }\n  await page.goto(BOSS_GEEK_JOBS_URL);\n  await page.wait(3);\n  const probe = await page.evaluate(`\n    (() => {\n      const path = location.pathname || '';\n      if (/\\\\/web\\\\/user\\\\/login|\\\\/login\\\\.html/.test(location.href)) {\n        return { kind: 'auth', detail: 'Boss redirected to login page' };\n      }\n      const userType = /\\\\/web\\\\/geek\\\\//.test(path) ? 'geek' : /\\\\/web\\\\/(boss|recruit|chat\\\\/boss)/.test(path) ? 'recruiter' : '';\n      if (!userType) {\n        return { kind: 'auth', detail: 'Boss path does not look like authenticated geek/recruiter page: ' + path };\n      }\n      return { ok: true, user_type: userType };\n    })()\n  `);\n  if (probe?.kind === 'auth') throw new AuthRequiredError('zhipin.com', probe.detail);\n  if (!probe?.ok) throw new CommandExecutionError(`Unexpected Boss probe: ${JSON.stringify(probe)}`);\n  return { user_type: probe.user_type };\n}\n\nregisterSiteAuthCommands({\n  site: 'boss',\n  domain: 'zhipin.com',\n  loginUrl: 'https://login.zhipin.com/',\n  columns: ['user_type'],\n  quickCheck: hasBossSessionCookie,\n  verify: verifyBossIdentity,\n  poll: async (page) => {\n    if (!await hasBossSessionCookie(page)) {\n      throw new AuthRequiredError('zhipin.com', 'Waiting for Boss wt2 / t cookies');\n    }\n    return verifyBossIdentity(page);\n  },\n});\n","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/boss/auth.js#L15-L51","documentation":"After probing the page, verifyBossIdentity expects the evaluate result to be either {kind:'auth',...} or {ok:true,...}. If probe is undefined, malformed, or otherwise lacks both fields, it throws CommandExecutionError 'Unexpected Boss probe: <JSON>'. This guards against a broken probe result rather than a normal unauthenticated state — e.g. the page script failed to run or returned something unexpected.","triggerScenarios":"page.evaluate returns null/undefined (script blocked by CSP, page navigated away mid-probe, dialog intercepted), or returns an object without kind==='auth' and without ok:true (e.g. {ok:false}, a serialized error, or a different runtime shape).","commonSituations":"Page still loading SPA shell so the probe IIFE threw and the harness swallowed the result; automation browser injecting wrappers that change the return serialization; zhipin.com serving an error/interstitial page instead of the app; driver version returning wrapped evaluate results.","solutions":["Read the JSON in the error message to see what the probe actually returned and diagnose from that shape","Increase the post-navigation wait (page.wait) so the SPA finishes rendering before probing","Re-run the command; transient navigations or dialogs can swallow the probe result","Check whether zhipin.com served an error/waf interstitial page and switch IP/profile if so","If the driver wraps evaluate results, adjust the probe invocation to unwrap before returning"],"exampleFix":"// before\nconst probe = await page.evaluate(`(() => { ... })()`);\n// after\nawait page.waitForSelector('.page-jobs, [ka=\"header-logo\"]', { timeout: 10000 }).catch(() => {});\nconst probe = await page.evaluate(`(() => { try { ... } catch (e) { return { kind: 'probe-error', detail: String(e) }; } })()`);","handlingStrategy":"try-catch","validationCode":"// Ensure the SPA is interactive before probing\nawait page.goto('https://www.zhipin.com/web/geek/jobs');\nawait page.waitForLoadState?.('networkidle').catch(() => {});\nif (!/\\/web\\/(geek|boss|recruit|chat\\/boss)/.test(new URL(page.url()).pathname)) {\n  // not on an authenticated path; login/probe will be meaningless\n  console.warn('unexpected landing path:', page.url());\n}","typeGuard":"function isWellFormedProbe(probe) {\n  return probe !== null && typeof probe === 'object' &&\n    (probe.kind === 'auth' || probe.ok === true);\n}","tryCatchPattern":"try {\n  const identity = await bossVerify(page);\n} catch (err) {\n  if (err instanceof CommandExecutionError && err.message.startsWith('Unexpected Boss probe')) {\n    // parse the JSON after the prefix to see what actually came back\n    const raw = err.message.slice('Unexpected Boss probe: '.length);\n    console.error('probe result:', raw);\n    // retry once after a longer wait\n    await page.waitForTimeout(3000);\n    return bossVerify(page);\n  }\n  throw err;\n}","preventionTips":["Allow sufficient settle time after navigation before running in-page probes","Keep the probe IIFE defensive: wrap in try/catch and always return a tagged object","Handle dialogs/overlays that can block script execution on zhipin.com pages","Update the adapter when zhipin.com SPA routing changes paths like /web/geek/"],"tags":["probe","page-evaluate","scraping","unexpected-response"],"backgroundTag":"unexpected-scrape-response-shape","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}