{"record":{"id":"1222f9afc526ae7e","repo":"jackwener/OpenCLI","slug":"hf-models-limit-must-be-100","errorCode":null,"errorMessage":"hf models limit must be <= 100","messagePattern":"hf models limit must be <= 100","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/hf/models.js","lineNumber":38,"sourceCode":"    args: [\n        { name: 'sort', type: 'string', default: 'downloads', help: `Sort key: ${SORT_OPTIONS.join(', ')}` },\n        { name: 'search', type: 'string', required: false, help: 'Optional name/owner substring filter (e.g. \"llama\", \"mistralai/\")' },\n        { name: 'pipeline', type: 'string', required: false, help: 'Filter by pipeline tag (e.g. text-generation, image-classification)' },\n        { name: 'limit', type: 'int', default: 20, help: 'Max models (max 100; one API page).' },\n    ],\n    columns: ['rank', 'id', 'author', 'pipelineTag', 'downloads', 'likes', 'tags', 'lastModified', 'url'],\n    func: async (args) => {\n        const sortRaw = String(args.sort ?? 'downloads').toLowerCase();\n        const sort = SORT_ALIAS[sortRaw] ?? sortRaw;\n        if (!SORT_OPTIONS.includes(sort)) {\n            throw new ArgumentError(`hf models sort must be one of ${SORT_OPTIONS.join(', ')}`);\n        }\n        const limit = Number(args.limit ?? 20);\n        if (!Number.isInteger(limit) || limit <= 0) {\n            throw new ArgumentError('hf models limit must be a positive integer');\n        }\n        if (limit > 100) {\n            throw new ArgumentError('hf models limit must be <= 100');\n        }\n\n        const url = new URL('https://huggingface.co/api/models');\n        url.searchParams.set('sort', sort);\n        url.searchParams.set('direction', '-1');\n        url.searchParams.set('limit', String(limit));\n        url.searchParams.set('full', 'true');\n        if (args.search) url.searchParams.set('search', String(args.search));\n        if (args.pipeline) url.searchParams.set('pipeline_tag', String(args.pipeline));\n\n        let resp;\n        try {\n            resp = await fetch(url, {\n                headers: {\n                    'Accept': 'application/json',\n                    'User-Agent': 'opencli/1.0 (+https://github.com/jackwener/opencli)',\n                },\n            });","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/hf/models.js#L20-L56","documentation":"ArgumentError thrown at clis/hf/models.js:38 when the --limit argument is a valid positive integer but exceeds the CLI's hard cap of 100, which matches a single page of the Hugging Face /api/models endpoint. The library enforces this client-side rather than silently truncating or making paginated requests.","triggerScenarios":"Running `hf models --limit 101` or higher, e.g. --limit 500 or --limit 1000, when trying to list more models than one API page can return.","commonSituations":"Expecting the CLI to paginate like the HF hub library does; wanting a full catalog export in one call; copying a limit from a script that used the un-paginated API with large limits.","solutions":["Lower --limit to 100 or less (the maximum supported per call).","Use --search or --pipeline filters to narrow results so fewer than 100 rows are needed.","Run multiple invocations with different --search or --pipeline values to cover more models across calls.","Paginated fetching beyond one page is not implemented; it would require changes to clis/hf/models.js."],"exampleFix":"// before\nopencli hf models --limit 500\n// after\nopencli hf models --limit 100","handlingStrategy":"validation","validationCode":"const n = Number(rawLimit ?? 20);\nif (!Number.isInteger(n) || n <= 0) throw new Error('limit must be a positive integer');\nif (n > 100) console.warn('hf models caps at 100 per call; clamping');\nconst safeLimit = Math.min(n, 100);","typeGuard":null,"tryCatchPattern":"try {\n  await run(`hf models --limit ${wanted}`);\n} catch (e) {\n  if (String(e.message).includes('limit must be <= 100')) {\n    console.error('Cap is 100 per call; splitting the request');\n    await run('hf models --limit 100');\n  } else throw e;\n}","preventionTips":["Clamp limits to Math.min(n, 100) in wrapper scripts.","Use --search/--pipeline to narrow results instead of asking for more rows.","Remember the CLI fetches a single API page — no auto-pagination.","Cap at 100 in any UI or config that feeds this flag."],"tags":["argument-validation","cli","limit-exceeded","huggingface"],"backgroundTag":"limit-exceeded","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}