{"record":{"id":"3213a2dd41a756da","repo":"jackwener/OpenCLI","slug":"probe-detail-3213a2","errorCode":null,"errorMessage":"${probe.detail}","messagePattern":"\\$\\{probe\\.detail\\}","errorType":"exception","errorClass":"AuthRequiredError","httpStatus":null,"severity":"error","filePath":"clis/upwork/auth.js","lineNumber":35,"sourceCode":"    (() => {\n      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});","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/upwork/auth.js#L17-L53","documentation":"When the in-page probe executed by verifyUpworkIdentity reports kind === 'auth', the code rethrows AuthRequiredError using the probe's own detail message. This means the page-level script detected Upwork redirected or presented a login/auth wall despite cookies existing.","triggerScenarios":"hasUpworkSessionCookie passed (cookies exist) but the page.evaluate probe detects location.pathname matching login/signup/account-security routes or profile lookup fails with an auth-kind result — stale or invalid cookies that still exist but no longer authenticate.","commonSituations":"Upwork invalidated the session server-side (cookies present but dead); session rotated and old tokens rejected; partial cookie state after a logout; Upwork A/B routing to /ab/ paths for unauthenticated users.","solutions":["Log in to upwork.com again in the connected browser to refresh the stale session, then retry.","Clear upwork.com cookies and perform a fresh login so XSRF/user_uid/master token are consistent.","Run the library's interactive login flow for upwork.com instead of relying on leftover cookies.","Retry after confirming https://www.upwork.com/nx/find-work/ loads without redirecting to a login page."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const cookies = await page.cookies('https://www.upwork.com');\nif (!hasUpworkSessionCookie(cookies)) throw new Error('No Upwork cookies — log in first');\nawait page.goto('https://www.upwork.com/nx/find-work/');\nif (/\\/(ab|account-security\\/login|signup)\\//.test(new URL(page.url()).pathname)) throw new Error('Session dead — re-authenticate');","typeGuard":"function isAuthProbe(p) { return !!p && typeof p === 'object' && p.kind === 'auth'; }","tryCatchPattern":"try {\n  await verifyUpworkIdentity(page);\n} catch (e) {\n  if (e instanceof AuthRequiredError) {\n    await clearUpworkCookies(page);   // stale cookies that no longer authenticate\n    await runInteractiveLogin(page);\n  } else throw e;\n}","preventionTips":["Treat existing-but-stale cookies as expired: re-login when identity verification fails.","Validate the session by loading /nx/find-work/ and checking for login redirects before commands.","Don't reuse cookie jars across long periods; refresh before job runs.","Clear Upwork cookies fully before re-authenticating to avoid mixed token states."],"tags":["auth","session-expired","upwork"],"backgroundTag":"session-expired","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}