{"record":{"id":"1995338808baee11","repo":"jackwener/OpenCLI","slug":"hf-spaces-sdk-must-be-one-of-gradio-streamlit","errorCode":null,"errorMessage":"hf spaces sdk must be one of gradio / streamlit / docker / static","messagePattern":"hf spaces sdk must be one of gradio / streamlit / docker / static","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/hf/spaces.js","lineNumber":44,"sourceCode":"    ],\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, {\n                headers: { Accept: 'application/json', 'User-Agent': 'opencli/1.0 (+https://github.com/jackwener/opencli)' },\n            });\n        }\n        catch (err) {\n            throw new CommandExecutionError(`hf spaces request failed: ${err?.message ?? err}`);","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/hf/spaces.js#L26-L62","documentation":"`hf spaces` validates the optional `sdk` filter against the fixed set of Space SDKs Hugging Face supports: '' (no filter), gradio, streamlit, docker, and static. Unknown SDK names throw this ArgumentError before the API call.","triggerScenarios":"Running `hf spaces --sdk pytorch`, `--sdk transformers`, or any value not in {gradio, streamlit, docker, static} (case-insensitive; value is trimmed and lowercased first, so 'Gradio ' works).","commonSituations":"Confusing model/pipeline libraries (transformers, pytorch, tensorflow) with Space SDKs; copying SDK values from `hf models`; guessing that 'space' or 'js' are valid SDKs.","solutions":["Use one of: gradio, streamlit, docker, static (e.g. `hf spaces --sdk gradio`).","Omit `--sdk` entirely to list all Spaces regardless of SDK.","Check https://huggingface.co/spaces to see which SDKs Spaces actually use.","Catch ArgumentError and validate/normalize the sdk value in your wrapper before invoking."],"exampleFix":"// before\nhf spaces --sdk transformers\n// after\nhf spaces --sdk gradio   // SDKs are gradio / streamlit / docker / static","handlingStrategy":"validation","validationCode":"const allowedSdks = new Set(['', 'gradio', 'streamlit', 'docker', 'static']);\nconst sdk = rawSdk == null ? '' : String(rawSdk).trim().toLowerCase();\nif (!allowedSdks.has(sdk)) throw new Error(`sdk must be one of gradio / streamlit / docker / static`);","typeGuard":"function isValidSdk(v) {\n  return ['gradio', 'streamlit', 'docker', 'static'].includes(String(v ?? '').trim().toLowerCase());\n}","tryCatchPattern":"try {\n  await run(['hf', 'spaces', '--sdk', rawSdk]);\n} catch (err) {\n  if (err instanceof ArgumentError && /sdk must be one of/.test(err.message)) {\n    console.warn(`Unknown SDK \"${rawSdk}\"; listing all Spaces`);\n    await run(['hf', 'spaces']);\n  } else throw err;\n}","preventionTips":["Only pass Space SDKs (gradio/streamlit/docker/static), not model libraries like transformers or pytorch","Normalize case and whitespace before passing --sdk; the CLI trims and lowercases for you","Omit --sdk entirely when you do not need an SDK filter","Validate against a whitelist in scripts that accept user-supplied SDK values"],"tags":["huggingface","argument-validation","cli","invalid-argument"],"backgroundTag":"invalid-argument-value","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}