jackwener/OpenCLI · error · CliError
INVALID_ARGS
INVALID_ARGS
Error message
Volume must be between 0 and 100
What it means
The spotify volume command rounds its positional 'level' argument and rejects values outside 0–100 with INVALID_ARGS, since Spotify's volume_percent endpoint only accepts that range. Note Math.round means fractional inputs like 100.4 pass as 100, but integers below 0 or above 100 always throw.
Source
Thrown at clis/spotify/spotify.js:259
strategy: Strategy.PUBLIC,
browser: false,
args: [],
columns: ['status'],
func: async () => { await api('POST', '/me/player/previous'); return [{ status: 'skipped to previous' }]; },
});
cli({
site: 'spotify',
name: 'volume',
access: 'write',
description: 'Set playback volume (0-100)',
strategy: Strategy.PUBLIC,
browser: false,
args: [{ name: 'level', type: 'int', default: 50, positional: true, required: true, help: 'Volume 0–100' }],
columns: ['volume'],
func: async (kwargs) => {
const level = Math.round(kwargs.level);
if (level < 0 || level > 100)
throw new CliError('INVALID_ARGS', 'Volume must be between 0 and 100');
await api('PUT', `/me/player/volume?volume_percent=${level}`);
return [{ volume: `${level}%` }];
},
});
cli({
site: 'spotify',
name: 'search',
access: 'read',
description: 'Search for tracks',
strategy: Strategy.PUBLIC,
browser: false,
args: [
{ name: 'query', type: 'str', required: true, positional: true, help: 'Search query' },
{ name: 'limit', type: 'int', default: 10, help: 'Number of results (default: 10)' },
],
columns: ['track', 'artist', 'album', 'uri'],
func: async (kwargs) => {
const limit = Math.min(50, Math.max(1, Math.round(kwargs.limit)));View on GitHub (pinned to 49907e53dc)
Solutions
- Pass an integer between 0 and 100: opencli spotify volume 50.
- Clamp computed values before invoking: Math.min(100, Math.max(0, level)).
- If using 0–1 scale in your script, multiply by 100 first.
Example fix
// before opencli spotify volume 150 // INVALID_ARGS // after opencli spotify volume 100
Defensive patterns
Strategy: validation
Validate before calling
const level = Math.round(Number(raw));
if (!Number.isFinite(level) || level < 0 || level > 100) throw new Error(`volume must be 0-100, got ${raw}`); Try / catch
try {
await run(['spotify', 'volume', String(level)]);
} catch (e) {
if (e.message.includes('Volume must be between 0 and 100')) {
level = Math.min(100, Math.max(0, Math.round(level)));
await run(['spotify', 'volume', String(level)]);
} else throw e;
} Prevention
- Clamp to [0,100] with Math.min/Math.max before invoking.
- Convert 0–1 normalized audio levels to percent (x * 100) first.
- Round fractional inputs since the command applies Math.round.
When it happens
Trigger: Running opencli spotify volume with level < 0 (e.g. -10) or > 100 (e.g. 150); scripts computing percentages that overshoot 100 or go negative.
Common situations: Users expecting 0–1 normalized values (passing 0.9 then rounding to 1 works, but passing 150 fails); automation multiplying volume and exceeding 100; sign/typo errors producing negatives.
Related errors
- ${label} must be between ${min} and ${max}, got ${parsed}
- ${label} must be <= ${max}
- --${name} must be between ${min} and ${max}, got ${parsed}
- flomo memos --${name} must be between 1 and ${max}
- limit must be an integer between 1 and ${max}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/b2fff1a6e526e4d3.
Report an issue: GitHub.