{"record":{"id":"8f1c0a22e95e66e7","repo":"jackwener/OpenCLI","slug":"hf-spaces-limit-must-be-100","errorCode":null,"errorMessage":"hf spaces limit must be <= 100","messagePattern":"hf spaces limit must be <= 100","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/hf/spaces.js","lineNumber":39,"sourceCode":"    args: [\n        { name: 'sort', type: 'string', default: 'likes', help: `Sort key: ${SORT_OPTIONS.join(', ')}` },\n        { name: 'search', type: 'string', required: false, help: 'Optional name/owner substring filter (e.g. \"stability\", \"openai/\")' },\n        { name: 'sdk', type: 'string', required: false, help: 'Filter by Space SDK: gradio / streamlit / docker / static' },\n        { name: 'limit', type: 'int', default: 20, help: 'Max spaces (max 100; one API page).' },\n    ],\n    columns: ['rank', 'id', 'author', 'sdk', 'likes', 'tags', 'lastModified', 'url'],\n    func: async (args) => {\n        const sortRaw = String(args.sort ?? 'likes').toLowerCase();\n        const sort = SORT_ALIAS[sortRaw] ?? sortRaw;\n        if (!SORT_OPTIONS.includes(sort)) {\n            throw new ArgumentError(`hf spaces 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 spaces limit must be a positive integer');\n        }\n        if (limit > 100) {\n            throw new ArgumentError('hf spaces limit must be <= 100');\n        }\n        const sdk = args.sdk == null ? '' : String(args.sdk).trim().toLowerCase();\n        const allowedSdks = new Set(['', 'gradio', 'streamlit', 'docker', 'static']);\n        if (!allowedSdks.has(sdk)) {\n            throw new ArgumentError(`hf spaces sdk must be one of gradio / streamlit / docker / static`);\n        }\n\n        const url = new URL('https://huggingface.co/api/spaces');\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 (sdk) url.searchParams.set('sdk', sdk);\n\n        let resp;\n        try {\n            resp = await fetch(url, {","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/hf/spaces.js#L21-L57","documentation":"`hf spaces` caps `limit` at 100 because it fetches a single API page from huggingface.co/api/spaces. Requesting more than 100 throws this ArgumentError up front rather than silently clamping or paginating.","triggerScenarios":"Running `hf spaces --limit 200`, `--limit 1000`, or computing a limit above 100 to 'get everything' in one call.","commonSituations":"Trying to export a large list of Spaces in one command; assuming the CLI paginates like other tools; porting scripts from APIs that allow larger page sizes.","solutions":["Use `--limit 100`, the maximum allowed per request.","Issue multiple calls (e.g. with different `--search` filters) if you need broader coverage.","Catch ArgumentError and clamp: `limit = Math.min(limit, 100)` in your wrapper.","Request pagination support upstream if you genuinely need >100 results."],"exampleFix":"// before\nhf spaces --limit 500\n// after\nhf spaces --limit 100","handlingStrategy":"validation","validationCode":"const n = Number(rawLimit ?? 20);\nconst limit = Math.min(Math.max(1, Number.isInteger(n) ? n : 20), 100);","typeGuard":"function isWithinLimitCap(v) {\n  return Number.isInteger(v) && v > 0 && v <= 100;\n}","tryCatchPattern":"try {\n  await run(['hf', 'spaces', '--limit', String(rawLimit)]);\n} catch (err) {\n  if (err instanceof ArgumentError && /limit must be <= 100/.test(err.message)) {\n    console.warn('Limit capped at 100 (single API page); retrying with 100');\n    await run(['hf', 'spaces', '--limit', '100']);\n  } else throw err;\n}","preventionTips":["Clamp limit to 100 before invoking the CLI","Do not expect pagination — the command fetches a single API page","Split large exports into multiple calls with different --search filters","Document the 100-item cap in any script that exposes a --limit flag"],"tags":["huggingface","argument-validation","cli","limit-exceeded"],"backgroundTag":"limit-exceeded","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}