jackwener/OpenCLI · error · ArgumentError

minimax music ${flag} must be at most ${max} characters

Error message

minimax music ${flag} must be at most ${max} characters

What it means

text() trims string options and enforces a maximum length: prompt is capped at 2000 chars and lyrics at 3500 chars. Exceeding the cap throws this ArgumentError so over-long payloads are rejected before spending API quota.

Source

Thrown at clis/minimax/music.js:58

    if (value == null || value === '') return null;
    const parsed = Number(value);
    if (!Number.isInteger(parsed) || !allowed.includes(parsed)) {
        throw new ArgumentError(`minimax music ${flag} must be one of: ${allowed.join(', ')}`);
    }
    return parsed;
}

function boundedInteger(value, fallback, min, max, flag) {
    const parsed = Number(value ?? fallback);
    if (!Number.isInteger(parsed) || parsed < min || parsed > max) {
        throw new ArgumentError(`minimax music ${flag} must be an integer from ${min} to ${max}`);
    }
    return parsed;
}

function text(value, max, flag) {
    const normalized = String(value ?? '').trim();
    if (normalized.length > max) throw new ArgumentError(`minimax music ${flag} must be at most ${max} characters`);
    return normalized;
}

cli({
    site: 'minimax',
    name: 'music',
    access: 'write',
    description: 'Generate music for legacy paid MiniMax Music API accounts',
    domain: 'api.minimax.io',
    strategy: Strategy.PUBLIC,
    browser: false,
    args: [
        { name: 'prompt', positional: true, help: 'Music style, mood, and scenario (max 2000 characters)' },
        { name: 'lyrics', help: 'Lyrics with section tags and newlines (max 3500 characters)' },
        { name: 'model', default: 'music-3.0', choices: MODELS, help: 'Legacy paid generation model' },
        { name: 'region', default: 'global', choices: Object.keys(MUSIC_REGIONS), help: 'API deployment: global or cn' },
        { name: 'output-format', default: 'url', choices: OUTPUT_FORMATS, help: 'Return a 24-hour URL or save inline hex audio' },
        { name: 'audio-format', default: 'mp3', choices: AUDIO_FORMATS, help: 'Rendered audio format' },

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Shorten the value under the cap shown in the message (prompt ≤ 2000, lyrics ≤ 3500)
  2. Pre-check length in your script: if (text.length > 3500) truncate or split the request
  3. Strip comments/headers/metadata from lyric files before passing them
  4. Use the error message's ${flag} and ${max} to identify which option overflowed

Example fix

// before
minimax music --lyrics "$(cat full_song_with_notes.txt)"   # 4200 chars
// after
minimax music --lyrics "$(head -c 3500 lyrics_only.txt)"
Defensive patterns

Strategy: validation

Validate before calling

function assertLen(v, max, name) {
  const s = String(v ?? '').trim();
  if (s.length > max) throw new Error(`${name} is ${s.length} chars, max ${max}`);
}
assertLen(prompt, 2000, 'prompt');
assertLen(lyrics, 3500, 'lyrics');

Try / catch

try {
  runMinimaxMusic(args);
} catch (e) {
  const m = e.message.match(/--?(\S+) must be at most (\d+) characters/);
  if (m) { console.error(`Shorten ${m[1]} to <= ${m[2]} chars`); process.exitCode = 2; }
  else throw e;
}

Prevention

When it happens

Trigger: --prompt with more than 2000 characters of scene description; --lyrics with more than 3500 characters (e.g. piping a whole song's lyrics including metadata, or a file whose contents were pasted with a header).

Common situations: Generating prompts from templates that grow past the cap; loading lyrics from long text files or scraped pages with extra whitespace/newlines; not realizing the trim() still counts newlines inside the text toward the length.

Related errors


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