jackwener/OpenCLI · error · CommandExecutionError

CreateList returned a list payload without list mode.

Error message

CreateList returned a list payload without list mode.

What it means

requireCreateListResult requires the CreateList response to include a string `mode` field (public/private). It throws when the payload has no mode or a non-string mode. Mode is required so the CLI can verify the list's privacy setting matches what the user requested.

Solutions

  1. Log the raw response payload to confirm which fields Twitter now returns
  2. Update the parser/queryId+FEATURES to match the current CreateList schema
  3. Retry the command in case of a transient partial response
  4. Add a fallback that re-fetches the list by id to read its mode

Example fix

// before
const modeValue = typeof list.mode === 'string' ? list.mode : '';
// after
let modeValue = typeof list.mode === 'string' ? list.mode : '';
if (!modeValue && list.customizable !== undefined) modeValue = list.customizable ? 'private' : 'public'; // fallback field
Defensive patterns

Strategy: type-guard

Validate before calling

if (!result?.data?.create_list || typeof result.data.create_list.mode !== 'string') {
  throw new Error('CreateList payload missing mode');
}

Type guard

function hasListMode(list) {
  return !!list && typeof list === 'object' && (list.mode === 'public' || list.mode === 'private');
}

Try / catch

try {
  const row = buildListCreateRow({ result, name, description, mode });
} catch (e) {
  if (/without list mode/.test(e.message)) console.error('Response schema drifted; dump payload', JSON.stringify(result));
  else throw e;
}

Prevention

When it happens

Trigger: CreateList GraphQL response contains a list object without `mode` or with mode of a non-string type — schema drift, partial response, or mocked test payload missing mode.

Common situations: Twitter updates the CreateList response schema; an API gateway strips fields; unit-test fixtures omit mode.

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


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/f29e8be3af8abcf4. Report an issue: GitHub.

Appendix: source

Thrown at clis/twitter/list-create.js:74

        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)}`);
    }
    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',
    };
}

View on GitHub (pinned to 49907e53dc)