{"record":{"id":"b2fff1a6e526e4d3","repo":"jackwener/OpenCLI","slug":"invalid-args","errorCode":"INVALID_ARGS","errorMessage":"Volume must be between 0 and 100","messagePattern":"Volume must be between 0 and 100","errorType":"error_code","errorClass":"CliError","httpStatus":null,"severity":"error","filePath":"clis/spotify/spotify.js","lineNumber":259,"sourceCode":"    strategy: Strategy.PUBLIC,\n    browser: false,\n    args: [],\n    columns: ['status'],\n    func: async () => { await api('POST', '/me/player/previous'); return [{ status: 'skipped to previous' }]; },\n});\ncli({\n    site: 'spotify',\n    name: 'volume',\n    access: 'write',\n    description: 'Set playback volume (0-100)',\n    strategy: Strategy.PUBLIC,\n    browser: false,\n    args: [{ name: 'level', type: 'int', default: 50, positional: true, required: true, help: 'Volume 0–100' }],\n    columns: ['volume'],\n    func: async (kwargs) => {\n        const level = Math.round(kwargs.level);\n        if (level < 0 || level > 100)\n            throw new CliError('INVALID_ARGS', 'Volume must be between 0 and 100');\n        await api('PUT', `/me/player/volume?volume_percent=${level}`);\n        return [{ volume: `${level}%` }];\n    },\n});\ncli({\n    site: 'spotify',\n    name: 'search',\n    access: 'read',\n    description: 'Search for tracks',\n    strategy: Strategy.PUBLIC,\n    browser: false,\n    args: [\n        { name: 'query', type: 'str', required: true, positional: true, help: 'Search query' },\n        { name: 'limit', type: 'int', default: 10, help: 'Number of results (default: 10)' },\n    ],\n    columns: ['track', 'artist', 'album', 'uri'],\n    func: async (kwargs) => {\n        const limit = Math.min(50, Math.max(1, Math.round(kwargs.limit)));","sourceCodeStart":241,"sourceCodeEnd":277,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/spotify/spotify.js#L241-L277","documentation":"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.","triggerScenarios":"Running opencli spotify volume with level < 0 (e.g. -10) or > 100 (e.g. 150); scripts computing percentages that overshoot 100 or go negative.","commonSituations":"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.","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."],"exampleFix":"// before\nopencli spotify volume 150   // INVALID_ARGS\n// after\nopencli spotify volume 100","handlingStrategy":"validation","validationCode":"const level = Math.round(Number(raw));\nif (!Number.isFinite(level) || level < 0 || level > 100) throw new Error(`volume must be 0-100, got ${raw}`);","typeGuard":null,"tryCatchPattern":"try {\n  await run(['spotify', 'volume', String(level)]);\n} catch (e) {\n  if (e.message.includes('Volume must be between 0 and 100')) {\n    level = Math.min(100, Math.max(0, Math.round(level)));\n    await run(['spotify', 'volume', String(level)]);\n  } else throw e;\n}","preventionTips":["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."],"tags":["spotify","argument-validation","range-check"],"backgroundTag":"argument-out-of-range","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}