{"record":{"id":"c49751576b363ed0","repo":"jackwener/OpenCLI","slug":"instagram-whoami-failed-result-detail","errorCode":null,"errorMessage":"Instagram whoami failed: ${result.detail}","messagePattern":"Instagram whoami failed: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/instagram/auth.js","lineNumber":39,"sourceCode":"        headers: { 'X-IG-App-ID': '936619743392459', 'Accept': 'application/json' },\n      });\n      if (r.status === 401 || r.status === 403) {\n        return { kind: 'auth', detail: 'Instagram /users/info HTTP ' + r.status };\n      }\n      if (!r.ok) return { kind: 'http', httpStatus: r.status };\n      const d = await r.json();\n      const user = d?.user;\n      if (!user || !user.pk) {\n        return { kind: 'auth', detail: 'Instagram /users/info returned no pk — session likely expired' };\n      }\n      return { ok: true, user_id: String(user.pk), username: String(user.username || ''), full_name: String(user.full_name || '') };\n    } catch (e) {\n      return { kind: 'exception', detail: String(e && e.message || e) };\n    }\n  })()`);\n  if (result?.kind === 'auth') throw new AuthRequiredError('www.instagram.com', result.detail);\n  if (result?.kind === 'http') throw new CommandExecutionError(`HTTP ${result.httpStatus} from Instagram /users/info`);\n  if (result?.kind === 'exception') throw new CommandExecutionError(`Instagram whoami failed: ${result.detail}`);\n  if (!result?.ok) throw new CommandExecutionError(`Unexpected Instagram probe: ${JSON.stringify(result)}`);\n  return { user_id: result.user_id, username: result.username, full_name: result.full_name };\n}\n\nregisterSiteAuthCommands({\n  site: 'instagram',\n  domain: 'instagram.com',\n  loginUrl: 'https://www.instagram.com/accounts/login/',\n  columns: ['user_id', 'username', 'full_name'],\n  quickCheck: hasInstagramSessionCookie,\n  verify: verifyInstagramIdentity,\n  poll: async (page) => {\n    if (!await hasInstagramSessionCookie(page)) {\n      throw new AuthRequiredError('www.instagram.com', 'Waiting for Instagram sessionid cookie');\n    }\n    return verifyInstagramIdentity(page);\n  },\n});","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/instagram/auth.js#L21-L57","documentation":"A CommandExecutionError thrown when the in-page whoami IIFE threw a JavaScript exception; the probe catches it and returns {kind:'exception', detail}, and verifyInstagramIdentity re-throws as 'Instagram whoami failed: <detail>'. This means the probe script itself crashed (e.g. response.json() failed to parse, a network error inside the page, or an unexpected runtime error), not that Instagram returned an auth or HTTP status. The inner detail explains the actual failure.","triggerScenarios":"Any exception inside the probe's try block: fetch() rejecting due to a network/CORS failure inside the page, response.json() throwing on a non-JSON body (e.g. an HTML error page or checkpoint redirect), or a bug/type error in the probe code.","commonSituations":"Instagram serving an HTML interstitial (checkpoint, consent page) instead of JSON; browser network interrupted mid-request; a page navigation canceling the fetch; running against a modified or outdated page context.","solutions":["Read the inner detail in the message to identify the underlying exception","Open instagram.com in the CLI-controlled browser and check for checkpoints/captcha or consent prompts; resolve them manually","Re-run the command — transient network errors inside the page often resolve on retry","Log in again if Instagram keeps redirecting to a non-JSON response","Update the CLI if Instagram changed the /users/info response shape"],"exampleFix":"// diagnose the wrapped exception\ntry {\n  await opencli instagram whoami;\n} catch (e) {\n  if (e.message.startsWith('Instagram whoami failed:')) {\n    console.error('Inner cause:', e.message.slice('Instagram whoami failed:'.length));\n  }\n}","handlingStrategy":"try-catch","validationCode":"null","typeGuard":"null","tryCatchPattern":"try {\n  await instagramWhoami();\n} catch (e) {\n  if (e.message.startsWith('Instagram whoami failed:')) {\n    const cause = e.message.slice('Instagram whoami failed:'.length);\n    console.error('Probe crashed:', cause); // e.g. JSON parse failure, network error\n    return instagramWhoami(); // one retry for transient in-page failures\n  }\n  throw e;\n}","preventionTips":["Keep the browser on instagram.com and don't navigate/close it while commands run","Resolve Instagram checkpoints/captcha prompts manually — they return HTML that breaks JSON parsing","Retry once on transient network errors inside the page before failing","Keep the CLI up to date in case Instagram changes endpoint response shapes"],"tags":["instagram","runtime-exception","network","json"],"backgroundTag":"in-page-script-exception","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}