jackwener/OpenCLI · error · ArgumentError

List name is required

Error message

List name is required

What it means

parseListCreateArgs validates the arguments of `twitter list-create`. The list `name` is required: it is trimmed and, if empty, ArgumentError('List name is required') is thrown with a usage example. X lists require a non-empty name (max 25 chars), so creation cannot proceed without one.

Source

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

const DESCRIPTION_MAX = 100;

// Minimal feature set as observed in the real CreateList web request payload.
// Twitter rejects requests with extra/unknown features (DecodeException).
const FEATURES = {
    profile_label_improvements_pcf_label_in_post_enabled: true,
    responsive_web_profile_redirect_enabled: false,
    rweb_tipjar_consumption_enabled: false,
    verified_phone_label_enabled: false,
    responsive_web_graphql_skip_user_profile_image_extensions_enabled: false,
    responsive_web_graphql_timeline_navigation_enabled: true,
};

export function parseListCreateArgs(kwargs) {
    const name = String(kwargs.name || '').trim();
    const description = String(kwargs.description || '').trim();
    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) {

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Pass the list name as the first positional argument, quoted if it contains spaces: opencli twitter list-create "My List".
  2. Check the shell variable or template field that supplies the name is non-empty before invoking.
  3. Remember subsequent constraints: name ≤ 25 chars, description ≤ 100 chars, mode public|private.

Example fix

// before
opencli twitter list-create --mode private
ArgumentError: List name is required
// after
opencli twitter list-create "My List" --mode private
Defensive patterns

Strategy: validation

Validate before calling

const name = String(args[0] || '').trim();
if (!name) throw new Error('Usage: opencli twitter list-create "My List" [--mode public|private] [--description "..."]');

Try / catch

try {
  await createList(argv);
} catch (e) {
  if (e instanceof ArgumentError && /List name is required/.test(e.message)) {
    console.error(e.message); // includes usage example
    process.exitCode = 2;
    return;
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling list-create without the positional name argument, or with an empty/whitespace-only name (e.g. opencli twitter list-create "" --mode private), so String(kwargs.name||'').trim() is ''.

Common situations: Quoting mistakes where the shell drops the argument; a variable holding the name is empty; a script builds the command from a template with a blank name field; passing only --description/--mode and forgetting the positional.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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