{"record":{"id":"6a4fa3533d9bb38f","repo":"jackwener/OpenCLI","slug":"coingecko-derivatives-limit-must-be-a-positive-int","errorCode":null,"errorMessage":"coingecko derivatives limit must be a positive integer","messagePattern":"coingecko derivatives limit must be a positive integer","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/coingecko/derivatives.js","lineNumber":30,"sourceCode":"const ENDPOINT = 'https://api.coingecko.com/api/v3/derivatives';\n\ncli({\n    site: 'coingecko',\n    name: 'derivatives',\n    access: 'read',\n    description: 'Top crypto derivative (perpetual / futures) markets by 24h volume',\n    domain: 'api.coingecko.com',\n    strategy: Strategy.PUBLIC,\n    browser: false,\n    args: [\n        { name: 'limit', type: 'int', default: 20, help: 'Max rows to return (1-500; CoinGecko returns one large page).' },\n        { name: 'symbol', type: 'string', required: false, help: 'Optional symbol substring filter (e.g. \"BTC\", \"ETHUSDT\").' },\n    ],\n    columns: ['rank', 'market', 'symbol', 'indexId', 'contractType', 'price', 'change24hPct', 'fundingRate', 'openInterestUsd', 'volume24hUsd', 'expired'],\n    func: async (args) => {\n        const limit = Number(args.limit ?? 20);\n        if (!Number.isInteger(limit) || limit <= 0) {\n            throw new ArgumentError('coingecko derivatives limit must be a positive integer');\n        }\n        if (limit > 500) {\n            throw new ArgumentError('coingecko derivatives limit must be <= 500');\n        }\n        const filter = args.symbol == null ? '' : String(args.symbol).trim().toUpperCase();\n        let resp;\n        try {\n            resp = await fetch(ENDPOINT, { headers: { 'User-Agent': 'Mozilla/5.0' } });\n        }\n        catch (err) {\n            throw new CommandExecutionError(`coingecko derivatives request failed: ${err?.message ?? err}`);\n        }\n        if (resp.status === 429) {\n            throw new CommandExecutionError(\n                'coingecko derivatives returned HTTP 429 (rate limited)',\n                'Free tier allows ~30 calls/min. Wait and retry.',\n            );\n        }","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/coingecko/derivatives.js#L12-L48","documentation":"This ArgumentError is thrown by the coingecko derivatives command's `func` when the `limit` argument, after coercion via Number(args.limit ?? 20), is not an integer or is <= 0. It guards the query parameter sent to the CoinGecko /derivatives endpoint so the API only receives a sensible page size. It fires before any network request is made.","triggerScenarios":"Calling the derivatives command with --limit set to a non-integer (e.g. 'abc', '2.5'), zero, or a negative number; passing an empty string that coerces to NaN.","commonSituations":"Typo'd CLI flag values, shell variables expanding to empty strings, scripts passing a float from computed values, users assuming a 0 or -1 limit means 'unlimited'.","solutions":["Pass an integer limit >= 1, e.g. --limit 20","Omit the --limit flag entirely to use the default of 20","If the value comes from config/script input, validate it is a positive integer before invoking"],"exampleFix":"// before\ncli derivatives --limit 0\n// after\ncli derivatives --limit 20","handlingStrategy":"validation","validationCode":"function isValidLimit(v) {\n  const n = Number(v ?? 20);\n  return Number.isInteger(n) && n > 0;\n}\nif (!isValidLimit(args.limit)) throw new Error('limit must be a positive integer');","typeGuard":"const isPositiveInt = (v) => typeof v === 'number' && Number.isInteger(v) && v > 0;","tryCatchPattern":null,"preventionTips":["Always pass whole numbers for limit","Rely on the default (20) when unsure","Validate CLI inputs with a schema before invoking commands"],"tags":["validation","argument-error","input-validation","cli"],"backgroundTag":"invalid-argument-value","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}