jackwener/OpenCLI · critical · CommandExecutionError
CreateList returned mode ${mode}, expected ${expectedMode}.
Error message
CreateList returned mode ${mode}, expected ${expectedMode}. What it means
After normalizing mode (any value matching /private/i becomes 'private', otherwise 'public'), requireCreateListResult compares it to the mode the user requested. It throws when the created list's mode differs from expectedMode — e.g. you asked for private but Twitter created a public list. This is a safety check so private lists are never silently created as public.
Source
Thrown at clis/twitter/list-create.js:78
throw new CommandExecutionError(`CreateList returned no list payload. Body: ${String(result.bodyText || '').slice(0, 300)}`);
}
const id = String(list.id_str || list.id || '');
if (!/^\d+$/.test(id)) {
throw new CommandExecutionError('CreateList returned a list payload without a numeric list id.');
}
if (typeof list.name !== 'string' || !list.name.trim()) {
throw new CommandExecutionError('CreateList returned a list payload without a list name.');
}
if (list.name.trim() !== expectedName) {
throw new CommandExecutionError(`CreateList returned name ${JSON.stringify(list.name)}, expected ${JSON.stringify(expectedName)}.`);
}
const modeValue = typeof list.mode === 'string' ? list.mode : '';
if (!modeValue) {
throw new CommandExecutionError('CreateList returned a list payload without list mode.');
}
const mode = /private/i.test(modeValue) ? 'private' : 'public';
if (mode !== expectedMode) {
throw new CommandExecutionError(`CreateList returned mode ${mode}, expected ${expectedMode}.`);
}
return { createdList: list, listId: id, listMode: mode };
}
export function buildListCreateRow({ result, name, description, mode }) {
const { createdList, listId, listMode } = requireCreateListResult(result, name, mode);
return {
id: listId,
name: createdList.name,
description: typeof createdList.description === 'string' ? createdList.description : description,
mode: listMode,
status: 'success',
};
}
cli({
site: 'twitter',
name: 'list-create',View on GitHub (pinned to 49907e53dc)
Solutions
- Verify the GraphQL variables include isPrivate/mode correctly (CreateList uses `isPrivate: true` for private lists, not mode:"private")
- Inspect the response payload's mode to confirm what Twitter actually created
- Delete the wrongly-created list and recreate with corrected variables
- Re-check how the CLI derives expectedMode from --private/--mode flags
Example fix
// before
variables: JSON.stringify({ name, description, mode: expectedMode })
// after
variables: JSON.stringify({ name, description, isPrivate: expectedMode === 'private' }) Defensive patterns
Strategy: validation
Validate before calling
if (expectedMode !== 'public' && expectedMode !== 'private') throw new Error(`bad expectedMode: ${expectedMode}`);
const isPrivate = expectedMode === 'private'; // pass isPrivate in CreateList variables Type guard
function modeMatches(list, expectedMode) {
const m = /private/i.test(String(list?.mode || '')) ? 'private' : 'public';
return m === expectedMode;
} Try / catch
try {
const row = buildListCreateRow({ result, name, description, mode });
} catch (e) {
if (/returned mode/.test(e.message)) console.error('Mode mismatch — deleting wrongly-created list and aborting:', e.message);
else throw e;
} Prevention
- Send isPrivate:true (not mode:"private") in CreateList variables for private lists
- Verify expectedMode derivation from CLI flags
- Never ignore a mode mismatch on private lists — it leaks data
When it happens
Trigger: CreateList response mode normalizes to a value different from the requested mode string ('public'/'private') — wrong query variables (mode key typo), API ignoring the mode param, or expectedMode computed incorrectly from --private flag.
Common situations: Sending `mode` in the wrong spot of the GraphQL variables so Twitter defaults to public; parsing bug turning --private false into expected private; older API version ignoring the mode field.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- 获取关注列表失败: ${payload.message} (${payload.code})
- Timeline is private or unavailable to the current X account;
- twitter followers
- twitter following
- twitter likes
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/8dea0ff527047649.
Report an issue: GitHub.