jackwener/OpenCLI · error · Error
${label} failed: HTTP ${response.status}
Error message
${label} failed: HTTP ${response.status} What it means
Generic HTTP-failure branch of throwInstagramHttpError in profile.js: any non-OK status from the profile endpoints that is not 404/401/403 becomes '<label> failed: HTTP <status>'. Label identifies the endpoint (Instagram web_profile_info, feed-by-username, or users info).
Source
Thrown at clis/instagram/profile.js:34
const opts = { credentials: 'include', headers: { 'X-IG-App-ID': '936619743392459' } };
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) {
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);
}
function mapProfileUser(u, countFields) {
if (!u || typeof u !== 'object' || typeof u.username !== 'string' || !u.username.trim()) {
throw new Error('Instagram profile returned malformed user payload for: ' + username);
}
return {
username: u.username,
name: typeof u.full_name === 'string' ? u.full_name : '',
bio: (typeof u.biography === 'string' ? u.biography : '').replace(/\\n/g, ' ').substring(0, 120),
followers: countFields.followers(u),
following: countFields.following(u),
posts: countFields.posts(u),
verified: u.is_verified ? 'Yes' : 'No',
};
}
const r1 = await fetch(
'https://www.instagram.com/api/v1/users/web_profile_info/?username=' + encodeURIComponent(username),
optsView on GitHub (pinned to 49907e53dc)
Solutions
- Check the status code: 429 means back off and retry with exponential delay; 5xx means retry later
- Reduce request frequency / add delays between profile lookups to avoid 429
- Verify the session and X-IG-App-ID header are being sent (Instagram may 4xx without it)
- Check Instagram status/community reports if 5xx persists
- Update the CLI if Instagram changed endpoint requirements (new headers required)
Example fix
// before: single attempt, immediate throw
const r1 = await fetch(url, opts);
if (!r1.ok && r1.status !== 400) throwInstagramHttpError(r1, 'Instagram web_profile_info');
// after: retry 429/5xx with backoff
let r1 = await fetch(url, opts);
for (let i = 0; i < 3 && (r1.status === 429 || r1.status >= 500); i++) {
await new Promise((res) => setTimeout(res, 2000 * 2 ** i));
r1 = await fetch(url, opts);
}
if (!r1.ok && r1.status !== 400) throwInstagramHttpError(r1, 'Instagram web_profile_info'); Defensive patterns
Strategy: retry
Type guard
function isRetryableStatus(status) {
return status === 429 || status === 408 || (status >= 500 && status <= 599);
} Try / catch
try {
const profile = await instagramProfile(username);
} catch (e) {
const m = /failed: HTTP (\d+)/.exec(e.message || '');
if (m && (m[1] === '429' || m[1].startsWith('5'))) {
await sleep(exponentialBackoff(attempt));
return retryWithLimit(attempt + 1, 3);
}
throw e;
} Prevention
- Throttle profile lookups (add delays/jitter between requests) to avoid 429
- Implement exponential backoff with a retry cap for 429/5xx
- Monitor Instagram status during outages instead of hammering retries
- Send the X-IG-App-ID header on every request to avoid spurious 4xx
When it happens
Trigger: clis/instagram/profile receives 429 (rate limit), 5xx (Instagram outage), or other unexpected statuses from web_profile_info, feed/user/.../username, or users/<id>/info endpoints.
Common situations: Rate limiting after many rapid profile queries (429); Instagram server incidents (500/502/503); blocked client from too much automation; transient network middleboxes returning odd statuses.
Understand the failure class
Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.
Related errors
- autohome ${contextHint} HTTP ${resp.status}
- Ctrip flight API returned HTTP ${status || 'unknown'}
- dongchedi ${contextHint} HTTP ${resp.status}
- eastmoney convertible failed: HTTP ${resp.status}
- HTTP_ERROR
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/c658185d57104a13.
Report an issue: GitHub.