{"record":{"id":"74a3ef12a5713423","repo":"jackwener/OpenCLI","slug":"unexpected-upwork-probe-json-stringify-probe","errorCode":null,"errorMessage":"Unexpected Upwork probe: ${JSON.stringify(probe)}","messagePattern":"Unexpected Upwork probe: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/upwork/auth.js","lineNumber":36,"sourceCode":"      if (/\\\\/(ab|account-security\\\\/login|signup)\\\\//.test(location.pathname)) {\n        return { kind: 'auth', detail: 'Upwork redirected to login flow' };\n      }\n      const nuxt = (typeof window !== 'undefined' && window.__NUXT__) ? window.__NUXT__ : null;\n      const state = nuxt && (nuxt.state || (nuxt.data && nuxt.data[0]));\n      const user = state && (state.user || (state.auth && state.auth.user));\n      const profile = user && (user.profile || user);\n      if (!profile || !profile.id) {\n        return { kind: 'auth', detail: 'Upwork __NUXT__ has no profile id — anonymous' };\n      }\n      return {\n        ok: true,\n        user_id: String(profile.id || profile.uid || ''),\n        ciphertext: String(profile.ciphertext || ''),\n      };\n    })()\n  `);\n  if (probe?.kind === 'auth') throw new AuthRequiredError('upwork.com', probe.detail);\n  if (!probe?.ok) throw new CommandExecutionError(`Unexpected Upwork probe: ${JSON.stringify(probe)}`);\n  return { user_id: probe.user_id, ciphertext: probe.ciphertext };\n}\n\nregisterSiteAuthCommands({\n  site: 'upwork',\n  domain: 'upwork.com',\n  loginUrl: 'https://www.upwork.com/ab/account-security/login',\n  columns: ['user_id', 'ciphertext'],\n  quickCheck: hasUpworkSessionCookie,\n  verify: verifyUpworkIdentity,\n  poll: async (page) => {\n    if (!await hasUpworkSessionCookie(page)) {\n      throw new AuthRequiredError('upwork.com', 'Waiting for Upwork session cookies');\n    }\n    return verifyUpworkIdentity(page);\n  },\n});\n","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/upwork/auth.js#L18-L54","documentation":"If the in-page probe returns neither a known failure shape nor ok:true, verifyUpworkIdentity throws CommandExecutionError with the JSON-serialized probe. This guards against unexpected response shapes so silent garbage is never treated as a successful identity verification.","triggerScenarios":"page.evaluate returns null/undefined, a non-object (e.g. a string error), or an object without ok:true and without kind:'auth' — e.g. the probe script was altered by page context, ran on the wrong page (blank tab, extension page), or an exception inside the IIFE swallowed the return value.","commonSituations":"Connected browser sitting on about:blank or a non-Upwork page when the command runs; an extension or CSP blocking inline script evaluation; Upwork DOM/site changes breaking the probe's expected profile object; page navigation cancelling evaluation mid-flight.","solutions":["Navigate the connected browser to https://www.upwork.com/nx/find-work/ and ensure you're logged in, then retry.","Inspect the JSON in the error message — it shows the actual probe result and reveals what went wrong.","Retry after the page fully loads; evaluation during navigation can return undefined.","Update the library if Upwork changed its page structure (profile object shape) — an outdated probe is a common cause.","Re-attach the browser bridge / restart the browser if evaluate consistently returns null."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"await page.goto('https://www.upwork.com/nx/find-work/', { waitUntil: 'networkidle' });\nif (page.url().startsWith('about:blank') || !page.url().includes('upwork.com')) throw new Error('Browser not on an Upwork page');","typeGuard":"function isSuccessfulProbe(p) {\n  return !!p && typeof p === 'object' && p.ok === true && typeof p.user_id === 'string';\n}","tryCatchPattern":"try {\n  await verifyUpworkIdentity(page);\n} catch (e) {\n  if (e instanceof CommandExecutionError && e.message.startsWith('Unexpected Upwork probe')) {\n    // inspect e.message JSON, reload the page, retry once\n    await page.reload();\n    await verifyUpworkIdentity(page);\n  } else throw e;\n}","preventionTips":["Always navigate to a real Upwork page before running identity probes — never about:blank.","Wait for page load/network idle before page.evaluate so navigation doesn't cancel evaluation.","Keep the library updated; Upwork DOM changes can break the probe's return shape.","Inspect the JSON-serialized probe in the error message to diagnose the actual in-page result."],"tags":["upwork","browser-automation","unexpected-response"],"backgroundTag":"unexpected-payload-shape","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}