{"record":{"id":"1be59276f98ae306","repo":"jackwener/OpenCLI","slug":"linkedin-whoami-failed-result-detail","errorCode":null,"errorMessage":"LinkedIn whoami failed: ${result.detail}","messagePattern":"LinkedIn whoami failed: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/linkedin/auth.js","lineNumber":44,"sourceCode":"      const mini = d && d.miniProfile;\n      if (!mini || !mini.publicIdentifier) {\n        return { kind: 'auth', detail: 'LinkedIn /voyager/api/me 200 but miniProfile missing' };\n      }\n      const firstName = (mini.firstName && (mini.firstName.text || mini.firstName)) || '';\n      const lastName = (mini.lastName && (mini.lastName.text || mini.lastName)) || '';\n      return {\n        ok: true,\n        public_id: String(mini.publicIdentifier),\n        plain_id: String(d.plainId || ''),\n        name: String((firstName + ' ' + lastName).trim()),\n      };\n    } catch (e) {\n      return { kind: 'exception', detail: String(e && e.message || e) };\n    }\n  })()`);\n  if (result?.kind === 'auth') throw new AuthRequiredError('linkedin.com', result.detail);\n  if (result?.kind === 'http') throw new CommandExecutionError(`HTTP ${result.httpStatus} from /voyager/api/me`);\n  if (result?.kind === 'exception') throw new CommandExecutionError(`LinkedIn whoami failed: ${result.detail}`);\n  if (!result?.ok) throw new CommandExecutionError(`Unexpected LinkedIn probe: ${JSON.stringify(result)}`);\n  return { public_id: result.public_id, plain_id: result.plain_id, name: result.name };\n}\n\nregisterSiteAuthCommands({\n  site: 'linkedin',\n  domain: 'www.linkedin.com',\n  loginUrl: 'https://www.linkedin.com/login',\n  columns: ['public_id', 'plain_id', 'name'],\n  quickCheck: hasLinkedinSessionCookie,\n  verify: verifyLinkedinIdentity,\n  poll: async (page) => {\n    if (!await hasLinkedinSessionCookie(page)) {\n      throw new AuthRequiredError('linkedin.com', 'Waiting for LinkedIn li_at cookie');\n    }\n    return verifyLinkedinIdentity(page);\n  },\n});","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/linkedin/auth.js#L26-L62","documentation":"The in-page whoami probe threw a JavaScript exception inside the browser context; the probe caught it and returned kind:'exception', which the library rethrows as CommandExecutionError('LinkedIn whoami failed: <detail>'). This is a client-side evaluation failure, not an HTTP error from LinkedIn.","triggerScenarios":"The async IIFE inside page.evaluate throws — e.g. fetch itself rejected (network/CORS/aborted), or code in the try block hit an unexpected shape before the guarded return.","commonSituations":"Automation browser lost connectivity mid-probe; a LinkedIn extension/override altering page JS; navigation interrupting the evaluate; older browser runtime lacking APIs the probe uses.","solutions":["Read result.detail in the message to identify the underlying exception, then fix accordingly.","Retry the command — transient navigation/network interruptions resolve on re-run.","Ensure the browser stays on a linkedin.com page and doesn't navigate during verification.","Update the headless browser runtime if the detail indicates a missing API."],"exampleFix":"// before\nawait run('linkedin whoami'); // LinkedIn whoami failed: Failed to fetch\n// after\nawait run('linkedin feed');   // ensure page loaded and network is up\nawait run('linkedin whoami'); // retry probe","handlingStrategy":"try-catch","validationCode":"// check basic connectivity before probing\nawait page.goto('https://www.linkedin.com/feed/', { waitUntil: 'domcontentloaded' });","typeGuard":"null","tryCatchPattern":"try {\n  await run('linkedin whoami');\n} catch (e) {\n  if (/LinkedIn whoami failed:/.test(e.message)) {\n    await sleep(2000);\n    return run('linkedin whoami'); // transient in-page exception\n  }\n  throw e;\n}","preventionTips":["Keep the automated browser on a stable linkedin.com page during probes.","Disable browser extensions that inject scripts.","Retry once on transient in-page exceptions."],"tags":["javascript","browser-automation","network"],"backgroundTag":"page-evaluate-exception","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}