{"record":{"id":"760b69f5fffb18c8","repo":"jackwener/OpenCLI","slug":"http-result-httpstatus-from-instagram-users-in","errorCode":null,"errorMessage":"HTTP ${result.httpStatus} from Instagram /users/info","messagePattern":"HTTP (.+?) from Instagram /users/info","errorType":"http","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/instagram/auth.js","lineNumber":38,"sourceCode":"        credentials: 'include',\n        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  },","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/instagram/auth.js#L20-L56","documentation":"A CommandExecutionError thrown when the whoami probe to Instagram's /api/v1/users/<uid>/info/ returns a non-ok status other than 401/403 (which would be auth errors instead). The library classifies this as a command-level HTTP failure rather than an auth problem, because the session may be fine but the API itself failed. The status code in the message indicates the actual problem.","triggerScenarios":"Inside the verifyInstagramIdentity page.evaluate probe, the fetch to /api/v1/users/<uid>/info/ with credentials:'include' and X-IG-App-ID header returns a status like 429 or 5xx, so the script returns {kind:'http', httpStatus}.","commonSituations":"Instagram rate limiting the account after heavy automated use (429); transient Instagram server errors (5xx); a network middlebox/proxy returning an unexpected response inside the page context.","solutions":["If status is 429, wait several minutes before retrying — Instagram rate limits the account/IP","For 5xx, retry after a short delay; usually transient","Reduce request frequency and add delays between Instagram CLI invocations","Retry after confirming you can browse instagram.com normally in the same browser profile"],"exampleFix":"// retry wrapper around the failing command\nasync function whoamiWithRetry(cmd, attempts = 3) {\n  for (let i = 0; i < attempts; i++) {\n    try { return await cmd(); }\n    catch (e) {\n      if (!/HTTP 5\\d\\d|HTTP 429/.test(e.message) || i === attempts - 1) throw e;\n      await new Promise(r => setTimeout(r, 60000));\n    }\n  }\n}","handlingStrategy":"retry","validationCode":"null","typeGuard":"null","tryCatchPattern":"try {\n  await instagramWhoami();\n} catch (e) {\n  const m = e.message.match(/HTTP (\\d+) from Instagram \\/users\\/info/);\n  if (m && (m[1] === '429' || m[1].startsWith('5'))) {\n    await sleep(m[1] === '429' ? 120000 : 5000);\n    return instagramWhoami();\n  }\n  throw e;\n}","preventionTips":["Rate-limit your Instagram automation; 429 means the account/IP is throttled","Retry 5xx with exponential backoff; they are usually transient","Note that 401/403 are surfaced as auth errors instead — route those to login, not retry","Monitor for repeated 429s and back off globally rather than per-command"],"tags":["http-error","rate-limit","instagram","retry"],"backgroundTag":"http-unexpected-status","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}