jackwener/OpenCLI · error

${label} failed: HTTP ${response.status}

Error message

${label} failed: HTTP ${response.status}

What it means

Generic HTTP failure path of throwInstagramHttpError: the Instagram API endpoint (label names which one, e.g. 'Instagram web_profile_info' or 'Instagram feed-by-username') returned a status that is not 404 (user-not-found) or 401/403 (auth). The library throws it as a catch-all for unexpected server responses like 429 (rate limit) or 5xx errors. The label in the message tells you which of the two fallback endpoints failed.

Source

Thrown at clis/instagram/_shared/user-id.js:28

    return `
  function normalizeInstagramUserId(value, label) {
    const id = typeof value === 'number' ? String(value) : (typeof value === 'string' ? value.trim() : '');
    if (!/^\\d+$/.test(id)) throw new Error(label);
    return id;
  }
  async function readInstagramJson(response, label) {
    try {
      return await response.json();
    } catch {
      throw new Error(label + ' returned invalid JSON');
    }
  }
  function throwInstagramHttpError(response, label, username) {
    if (response.status === 404) throw new Error('User not found: ' + username);
    if (response.status === 401 || response.status === 403) {
      throw new Error('HTTP ' + response.status + ' - make sure you are logged in to Instagram');
    }
    throw new Error(label + ' failed: HTTP ' + response.status);
  }
  const r1 = await fetch('https://www.instagram.com/api/v1/users/web_profile_info/?username=' + encodeURIComponent(username), opts);
  if (r1.status === 404) throw new Error('User not found: ' + username);
  if (!r1.ok && r1.status !== 400) throwInstagramHttpError(r1, 'Instagram web_profile_info', username);
  let userId = r1.ok ? normalizeInstagramUserId((await readInstagramJson(r1, 'Instagram web_profile_info'))?.data?.user?.id, 'Instagram web_profile_info returned no valid user id for: ' + username) : '';
  if (!userId) {
    const r1b = await fetch('https://www.instagram.com/api/v1/feed/user/' + encodeURIComponent(username) + '/username/?count=1', opts);
    if (!r1b.ok) throwInstagramHttpError(r1b, 'Instagram feed-by-username', username);
    userId = normalizeInstagramUserId((await readInstagramJson(r1b, 'Instagram feed-by-username'))?.user?.pk, 'Instagram feed returned no valid profile owner for: ' + username);
  }`;
}

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Read the HTTP status in the message: 429 means back off — wait several minutes before retrying
  2. For 5xx, retry after a short delay; it is usually transient on Instagram's side
  3. Slow down batch usage: add delays between username lookups to avoid rate limiting
  4. Disable VPN/proxy that may interfere, or retry from a different network
  5. If a specific status persists, check whether Instagram changed the API and update the CLI

Example fix

// before: rapid-fire lookups causing 429
for (const u of users) await getUserId(u); // Error: Instagram web_profile_info failed: HTTP 429

// after: throttle lookups
for (const u of users) {
  await getUserId(u);
  await new Promise(r => setTimeout(r, 3000));
}
Defensive patterns

Strategy: retry

Validate before calling

null

Type guard

null

Try / catch

try {
  await resolveInstagramUserId(username);
} catch (e) {
  const m = e.message.match(/failed: HTTP (\d+)/);
  if (m && (m[1] === '429' || m[1].startsWith('5'))) {
    await sleep(m[1] === '429' ? 120000 : 5000);
    return resolveInstagramUserId(username); // retry once with backoff
  }
  throw e;
}

Prevention

When it happens

Trigger: The fetch in buildResolveInstagramUserIdJs gets a response with an unhandled status — most commonly HTTP 429 (rate limited) or 5xx from web_profile_info, or a non-ok status from the feed-by-username fallback — and the error propagates out of the in-page script.

Common situations: Resolving many usernames in a row and hitting Instagram's rate limits (429); Instagram having a transient outage (5xx); a proxy/VPN or corporate network returning an unexpected status; Instagram A/B changes to endpoint behavior returning a new status code.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/8b944c6272003fe2. Report an issue: GitHub.