jackwener/OpenCLI · error · CommandExecutionError
Instagram whoami failed: ${result.detail}
Error message
Instagram whoami failed: ${result.detail} What it means
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.
Source
Thrown at clis/instagram/auth.js:39
headers: { 'X-IG-App-ID': '936619743392459', 'Accept': 'application/json' },
});
if (r.status === 401 || r.status === 403) {
return { kind: 'auth', detail: 'Instagram /users/info HTTP ' + r.status };
}
if (!r.ok) return { kind: 'http', httpStatus: r.status };
const d = await r.json();
const user = d?.user;
if (!user || !user.pk) {
return { kind: 'auth', detail: 'Instagram /users/info returned no pk — session likely expired' };
}
return { ok: true, user_id: String(user.pk), username: String(user.username || ''), full_name: String(user.full_name || '') };
} catch (e) {
return { kind: 'exception', detail: String(e && e.message || e) };
}
})()`);
if (result?.kind === 'auth') throw new AuthRequiredError('www.instagram.com', result.detail);
if (result?.kind === 'http') throw new CommandExecutionError(`HTTP ${result.httpStatus} from Instagram /users/info`);
if (result?.kind === 'exception') throw new CommandExecutionError(`Instagram whoami failed: ${result.detail}`);
if (!result?.ok) throw new CommandExecutionError(`Unexpected Instagram probe: ${JSON.stringify(result)}`);
return { user_id: result.user_id, username: result.username, full_name: result.full_name };
}
registerSiteAuthCommands({
site: 'instagram',
domain: 'instagram.com',
loginUrl: 'https://www.instagram.com/accounts/login/',
columns: ['user_id', 'username', 'full_name'],
quickCheck: hasInstagramSessionCookie,
verify: verifyInstagramIdentity,
poll: async (page) => {
if (!await hasInstagramSessionCookie(page)) {
throw new AuthRequiredError('www.instagram.com', 'Waiting for Instagram sessionid cookie');
}
return verifyInstagramIdentity(page);
},
});View on GitHub (pinned to 49907e53dc)
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
Example fix
// diagnose the wrapped exception
try {
await opencli instagram whoami;
} catch (e) {
if (e.message.startsWith('Instagram whoami failed:')) {
console.error('Inner cause:', e.message.slice('Instagram whoami failed:'.length));
}
} Defensive patterns
Strategy: try-catch
Validate before calling
null
Type guard
null
Try / catch
try {
await instagramWhoami();
} catch (e) {
if (e.message.startsWith('Instagram whoami failed:')) {
const cause = e.message.slice('Instagram whoami failed:'.length);
console.error('Probe crashed:', cause); // e.g. JSON parse failure, network error
return instagramWhoami(); // one retry for transient in-page failures
}
throw e;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- ${label} returned invalid JSON
- returned invalid JSON
- returned invalid JSON
- 12306 ${endpoint} returned an unexpected payload shape
- archive search returned malformed JSON: ${error?.message ||
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/c49751576b363ed0.
Report an issue: GitHub.