jackwener/OpenCLI · error · ArgumentError
${label} must be a number between 0 and 1
Error message
${label} must be a number between 0 and 1 What it means
clampSlider validates numeric slider-style options (weirdness, styleWeight) that Suno expects in the [0,1] range. Non-finite values (NaN/Infinity) or numbers outside 0–1 raise ArgumentError instead of being silently clamped.
Source
Thrown at clis/suno/utils.js:105
if (!Number.isInteger(n) || n < 1) {
throw new ArgumentError(`${label} must be a positive integer`);
}
return n;
}
export function requireNonNegativeInt(value, label) {
const n = Number(value);
if (!Number.isInteger(n) || n < 0) {
throw new ArgumentError(`${label} must be a non-negative integer`);
}
return n;
}
export function clampSlider(value, label, def) {
if (value === undefined || value === null || value === '') return def;
const n = Number(value);
if (!Number.isFinite(n) || n < 0 || n > 1) {
throw new ArgumentError(`${label} must be a number between 0 and 1`);
}
return n;
}
// ─────────────────────────────────────────────────────────────────────────────
// In-page helper snippets. Each is inlined into a page.evaluate() call so
// the browser-token is generated fresh per request and the Clerk token is
// pulled live (avoiding 60s TTL expiry on long polls).
// ─────────────────────────────────────────────────────────────────────────────
const BROWSER_TOKEN_JS = `JSON.stringify({ token: btoa(JSON.stringify({ timestamp: Date.now() })) })`;
const CLERK_TOKEN_JS = `await window.Clerk.session.getToken()`;
/**
* Build the standard header set used by every studio-api-prod.suno.com call.
*
* deviceId is read once per command and embedded literally; browser-token
* and Authorization are computed inline (timestamp/JWT refresh per call).View on GitHub (pinned to 49907e53dc)
Solutions
- Convert percentages to fractions: divide by 100 (75% → 0.75).
- Use a decimal point, not a comma, for fractional values.
- Omit the flag to use the built-in default when the value is undefined/null/''.
- Check the label in the message to see which slider option failed.
Example fix
// before opencli suno generate --prompt "song" --weirdness 75 // after opencli suno generate --prompt "song" --weirdness 0.75
Defensive patterns
Strategy: validation
Validate before calling
function inSliderRange(v) { const n = Number(v); return Number.isFinite(n) && n >= 0 && n <= 1; }
if (!inSliderRange(weirdness)) throw new Error('--weirdness must be a number between 0 and 1'); Type guard
function isSliderValue(v) {
const n = Number(v);
return Number.isFinite(n) && n >= 0 && n <= 1;
} Try / catch
try {
await run({ weirdness: clampSlider(rawWeirdness, 'weirdness', 0.5) });
} catch (err) {
if (err.name === 'ArgumentError' && /between 0 and 1/.test(err.message)) {
console.warn('Using default slider value');
} else throw err;
} Prevention
- Remember the range is 0–1, not 0–100; divide UI percentages by 100.
- Use decimal points, never comma decimals.
- Omit the flag to accept the default instead of guessing a value.
- Clamp programmatically: Math.min(1, Math.max(0, n)).
When it happens
Trigger: Passing `--weirdness 1.5` or `--style-weight 120` (percent-style values), `--weirdness abc` (NaN), or empty string not hitting the default-return branch — i.e. any value that is not a finite number between 0 and 1.
Common situations: Supplying percentages (0–100) from the Suno UI slider instead of fractions (0–1); typos like `1,0` in locales using comma decimals; shell variables expanding to empty/invalid strings.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- Unsupported --model "${model}"
- Either provide a Simple-mode prompt as the positional argume
- --tags and --negative-tags only apply in Custom mode (alongs
- All requested formats require --confirm-paid true
- Unsupported --formats value(s): ${unknown.join(', ')}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/db9ea3094b123087.
Report an issue: GitHub.