jackwener/OpenCLI · error
Instagram returned non-ok status: ${JSON.stringify(d).slice(
Error message
Instagram returned non-ok status: ${JSON.stringify(d).slice(0, 300)} What it means
Thrown when the create endpoint responds HTTP 200 but the JSON body's status field is present and not 'ok'. Instagram's private API signals logical failures (validation, spam detection, server-side issues) inside a 200 envelope, so this check catches those. The raw JSON is included truncated to 300 chars.
Source
Thrown at clis/instagram/collection-create.js:47
const fd = new FormData();
fd.append('name', trimmed);
fd.append('module_name', 'collection_create');
const res = await fetch('https://www.instagram.com/api/v1/collections/create/', {
method: 'POST',
credentials: 'include',
headers: {
'X-IG-App-ID': '936619743392459',
'X-CSRFToken': csrf,
},
body: fd,
});
if (!res.ok) {
const body = await res.text().catch(() => '');
throw new Error('Failed to create collection: HTTP ' + res.status + (body ? ' - ' + body.slice(0, 200) : ''));
}
const d = await res.json();
if (d?.status && d.status !== 'ok') {
throw new Error('Instagram returned non-ok status: ' + JSON.stringify(d).slice(0, 300));
}
return [{
status: 'Created',
collectionId: String(d?.collection_id ?? ''),
collectionName: String(d?.collection_name ?? trimmed),
mediaCount: d?.collection_media_count ?? 0,
}];
})()
` },
],
});
View on GitHub (pinned to 49907e53dc)
Solutions
- Inspect the included JSON for Instagram's message field
- Retry later if it looks like transient Instagram-side degradation
- Slow down request rate / add jitter to avoid automation detection
- Ensure the collection name doesn't contain characters Instagram rejects
Example fix
// before
if (d?.status && d.status !== 'ok') throw new Error('Instagram returned non-ok status: ' + ...);
// after
if (d?.status && d.status !== 'ok') {
if (d.message === 'please_wait_a_few_minutes') await sleep(120000); // transient
throw new Error('Instagram returned non-ok status: ' + ...);
} Defensive patterns
Strategy: try-catch
Validate before calling
// No pre-call validation possible; validate response shape after call
function isOkStatus(d) { return d && d.status === 'ok'; } Type guard
interface IgResponse { status?: string; message?: string }
function hasOkStatus(d: unknown): d is IgResponse & { status: 'ok' } {
return typeof d === 'object' && d !== null && (d as IgResponse).status === 'ok';
} Try / catch
try {
await createCollection(name);
} catch (e) {
if (String(e.message).startsWith('Instagram returned non-ok status')) {
console.warn('Instagram logical failure, retry later:', e.message);
return; // or schedule retry
}
throw e;
} Prevention
- Slow down automation to avoid Instagram anti-bot flags
- Inspect the embedded JSON for the message field to guide retries
- Handle HTTP-200-with-fail-status as a distinct failure class
- Avoid exotic characters in collection names
When it happens
Trigger: Instagram returns {status: 'fail', ...} for the create request — e.g. server-side rejection of the collection name, suspected automation, or partial service degradation despite HTTP 200.
Common situations: Automated collection creation flagged by Instagram anti-bot systems; transient Instagram API issues; payload accepted at HTTP layer but rejected logically.
Related errors
- Bilibili ${label} API returned a malformed payload
- Bilibili ${label} API failed: ${message} (${payload.code})
- Bilibili ${label} API returned malformed data
- Bilibili ${label} API did not return replies
- Bilibili ${label} API returned malformed replies
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/567e3a4cbd419d85.
Report an issue: GitHub.