jackwener/OpenCLI · error · CommandExecutionError
Unexpected result from twitter list-create: ${JSON.stringify
Error message
Unexpected result from twitter list-create: ${JSON.stringify(result)} What it means
This CommandExecutionError is thrown by requireCreateListResult when the unwrapped browser result is not a non-null object (e.g. null or undefined). It indicates the internal fetch-in-page pipeline failed to return a structured result rather than an HTTP-level problem. The message includes the JSON-stringified value received.
Source
Thrown at clis/twitter/list-create.js:42
const modeRaw = String(kwargs.mode || 'public').trim().toLowerCase();
if (!name) {
throw new ArgumentError('List name is required', 'Example: opencli twitter list-create "My List"');
}
if (name.length > NAME_MAX) {
throw new ArgumentError(`List name too long: ${name.length} chars (max ${NAME_MAX})`);
}
if (description.length > DESCRIPTION_MAX) {
throw new ArgumentError(`Description too long: ${description.length} chars (max ${DESCRIPTION_MAX})`);
}
if (modeRaw !== 'public' && modeRaw !== 'private') {
throw new ArgumentError(`Invalid mode: ${JSON.stringify(kwargs.mode)}. Expected "public" or "private".`);
}
return { listName: name, listDescription: description, listMode: modeRaw, privateFlag: modeRaw === 'private' };
}
function requireCreateListResult(result, expectedName, expectedMode) {
if (!result || typeof result !== 'object') {
throw new CommandExecutionError(`Unexpected result from twitter list-create: ${JSON.stringify(result)}`);
}
if (result.httpStatus === 401 || result.httpStatus === 403) {
throw new AuthRequiredError('x.com', `Twitter CreateList returned HTTP ${result.httpStatus}`);
}
if (!result.ok) {
const snippet = String(result.bodyText || '').slice(0, 300);
throw new CommandExecutionError(`HTTP ${result.httpStatus} from CreateList: ${snippet}`);
}
if (!result.bodyJson || typeof result.bodyJson !== 'object') {
throw new CommandExecutionError(`CreateList returned malformed JSON payload. Body: ${String(result.bodyText || '').slice(0, 300)}`);
}
const list = result.bodyJson?.data?.list;
if (!list || typeof list !== 'object') {
const errors = result.bodyJson?.errors;
if (Array.isArray(errors) && errors.length > 0) {
throw new CommandExecutionError(`CreateList failed: ${errors[0].message || JSON.stringify(errors[0])}`);
}
throw new CommandExecutionError(`CreateList returned no list payload. Body: ${String(result.bodyText || '').slice(0, 300)}`);View on GitHub (pinned to 49907e53dc)
Solutions
- Re-run the command; transient page/navigation failures often resolve on retry
- Verify the browser session and x.com login are healthy (AuthRequiredError would otherwise be raised for auth issues)
- Inspect the browser-automation setup (Playwright/CDP bridge) if it consistently returns null
- If calling buildListCreateRow yourself, pass the raw result object from the page.evaluate pipeline
Example fix
// before
const result = undefined;
const row = buildListCreateRow({ result, name, description, mode }); // throws
// after
const result = unwrapBrowserResult(await page.evaluate(fetchScript));
if (!result || typeof result !== 'object') throw new Error('browser returned no result');
const row = buildListCreateRow({ result, name, description, mode }); Defensive patterns
Strategy: type-guard
Validate before calling
const raw = unwrapBrowserResult(await page.evaluate(fetchScript));
if (raw == null || typeof raw !== 'object') {
throw new Error('CreateList pipeline returned no structured result');
} Type guard
function isCreateListResult(v) {
return v != null && typeof v === 'object' &&
typeof v.httpStatus === 'number' &&
typeof v.ok === 'boolean' &&
typeof v.bodyText === 'string';
} Try / catch
try {
const rows = await opencli.twitter.listCreate({ name, description, mode });
} catch (e) {
if (e instanceof CommandExecutionError && /Unexpected result from twitter list-create/.test(e.message)) {
// transient browser/pipeline failure: log and retry once with a fresh page
} else { throw e; }
} Prevention
- Ensure the browser automation runtime serializes evaluate() return values properly
- Avoid navigating away from the page while the in-page fetch is in flight
- When testing buildListCreateRow directly, always pass a well-formed result object
When it happens
Trigger: unwrapBrowserResult returning null/undefined because the in-page evaluate failed, was interrupted by navigation, or the browser automation layer returned nothing; passing a wrong-shaped object into buildListCreateRow.
Common situations: Browser/page crash or navigation during the fetch; older browser-automation runtime that doesn't serialize the return value; calling buildListCreateRow directly with a mocked/missing result in tests or custom code.
Related errors
- ${command} returned an unreadable browser payload
- LinkedIn search returned an unexpected response
- LinkedIn messengerMessages API returned an unexpected respon
- Unexpected Reuters probe: ${JSON.stringify(probe)}
- Unexpected Upwork probe: ${JSON.stringify(probe)}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/5ad0d751f6c882b2.
Report an issue: GitHub.