{"record":{"id":"8078f326938a8675","repo":"jackwener/OpenCLI","slug":"minimax-music-flag-must-be-at-most-max-chara","errorCode":null,"errorMessage":"minimax music ${flag} must be at most ${max} characters","messagePattern":"minimax music (.+?) must be at most (.+?) characters","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/minimax/music.js","lineNumber":58,"sourceCode":"    if (value == null || value === '') return null;\n    const parsed = Number(value);\n    if (!Number.isInteger(parsed) || !allowed.includes(parsed)) {\n        throw new ArgumentError(`minimax music ${flag} must be one of: ${allowed.join(', ')}`);\n    }\n    return parsed;\n}\n\nfunction boundedInteger(value, fallback, min, max, flag) {\n    const parsed = Number(value ?? fallback);\n    if (!Number.isInteger(parsed) || parsed < min || parsed > max) {\n        throw new ArgumentError(`minimax music ${flag} must be an integer from ${min} to ${max}`);\n    }\n    return parsed;\n}\n\nfunction text(value, max, flag) {\n    const normalized = String(value ?? '').trim();\n    if (normalized.length > max) throw new ArgumentError(`minimax music ${flag} must be at most ${max} characters`);\n    return normalized;\n}\n\ncli({\n    site: 'minimax',\n    name: 'music',\n    access: 'write',\n    description: 'Generate music for legacy paid MiniMax Music API accounts',\n    domain: 'api.minimax.io',\n    strategy: Strategy.PUBLIC,\n    browser: false,\n    args: [\n        { name: 'prompt', positional: true, help: 'Music style, mood, and scenario (max 2000 characters)' },\n        { name: 'lyrics', help: 'Lyrics with section tags and newlines (max 3500 characters)' },\n        { name: 'model', default: 'music-3.0', choices: MODELS, help: 'Legacy paid generation model' },\n        { name: 'region', default: 'global', choices: Object.keys(MUSIC_REGIONS), help: 'API deployment: global or cn' },\n        { name: 'output-format', default: 'url', choices: OUTPUT_FORMATS, help: 'Return a 24-hour URL or save inline hex audio' },\n        { name: 'audio-format', default: 'mp3', choices: AUDIO_FORMATS, help: 'Rendered audio format' },","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/minimax/music.js#L40-L76","documentation":"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.","triggerScenarios":"--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).","commonSituations":"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.","solutions":["Shorten the value under the cap shown in the message (prompt ≤ 2000, lyrics ≤ 3500)","Pre-check length in your script: if (text.length > 3500) truncate or split the request","Strip comments/headers/metadata from lyric files before passing them","Use the error message's ${flag} and ${max} to identify which option overflowed"],"exampleFix":"// before\nminimax music --lyrics \"$(cat full_song_with_notes.txt)\"   # 4200 chars\n// after\nminimax music --lyrics \"$(head -c 3500 lyrics_only.txt)\"","handlingStrategy":"validation","validationCode":"function assertLen(v, max, name) {\n  const s = String(v ?? '').trim();\n  if (s.length > max) throw new Error(`${name} is ${s.length} chars, max ${max}`);\n}\nassertLen(prompt, 2000, 'prompt');\nassertLen(lyrics, 3500, 'lyrics');","typeGuard":null,"tryCatchPattern":"try {\n  runMinimaxMusic(args);\n} catch (e) {\n  const m = e.message.match(/--?(\\S+) must be at most (\\d+) characters/);\n  if (m) { console.error(`Shorten ${m[1]} to <= ${m[2]} chars`); process.exitCode = 2; }\n  else throw e;\n}","preventionTips":["Truncate or split lyric/prompt text in scripts before invoking the CLI","Strip headers, notes and metadata from lyric files","Log .length of dynamic text during script development","Treat 2000 (prompt) and 3500 (lyrics) as hard constants in your tooling"],"tags":["cli","minimax","argument-validation","length-limit"],"backgroundTag":"input-length-exceeded","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}