{"record":{"id":"8c01ff595474f6a8","repo":"jackwener/OpenCLI","slug":"no-matching-spaces-on-huggingface-co","errorCode":null,"errorMessage":"No matching spaces on huggingface.co.","messagePattern":"No matching spaces on huggingface\\.co\\.","errorType":"exception","errorClass":"EmptyResultError","httpStatus":null,"severity":"warning","filePath":"clis/hf/spaces.js","lineNumber":82,"sourceCode":"        if (resp.status === 429) {\n            throw new CommandExecutionError(\n                'hf spaces returned HTTP 429 (rate limited)',\n                'Hugging Face throttles unauthenticated traffic; wait a few seconds and retry.',\n            );\n        }\n        if (!resp.ok) {\n            throw new CommandExecutionError(`hf spaces failed: HTTP ${resp.status}`);\n        }\n        let data;\n        try {\n            data = await resp.json();\n        }\n        catch (err) {\n            throw new CommandExecutionError(`hf spaces returned malformed JSON: ${err?.message ?? err}`);\n        }\n        const list = Array.isArray(data) ? data : [];\n        if (!list.length) {\n            throw new EmptyResultError('hf spaces', 'No matching spaces on huggingface.co.');\n        }\n        return list.slice(0, limit).map((s, i) => {\n            const id = String(s.id ?? s._id ?? '');\n            const slash = id.indexOf('/');\n            const author = String(s.author ?? (slash > 0 ? id.slice(0, slash) : ''));\n            const tags = Array.isArray(s.tags) ? s.tags.filter((t) => !String(t).startsWith('license:')).slice(0, 10).join(', ') : '';\n            return {\n                rank: i + 1,\n                id,\n                author,\n                sdk: String(s.sdk ?? ''),\n                likes: s.likes != null ? Number(s.likes) : null,\n                tags,\n                lastModified: String(s.lastModified ?? '').slice(0, 10),\n                url: id ? `https://huggingface.co/spaces/${id}` : '',\n            };\n        });\n    },","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/hf/spaces.js#L64-L100","documentation":"An EmptyResultError raised when the Hugging Face Spaces API returned valid JSON but the array was empty — no spaces matched the query. The library treats an empty result as an error so CLI callers get a clear 'nothing found' message rather than blank output.","triggerScenarios":"GET /api/spaces?search=... returns [] because no public space matches the search term, author, or filters; also when the API response is not an array (list defaults to []).","commonSituations":"Typo in the space name/author in the search query; querying a private or deleted space (not visible unauthenticated); overly restrictive filters; HF silently returning a non-array payload.","solutions":["Check the search term spelling and try a broader query","Verify the space exists at huggingface.co/<author>/<space> and is public","Remove filters (author, tags) and retry with fewer constraints","If the space is private/gated, authenticate with an HF token"],"exampleFix":"// before: single strict query\nawait hfSpaces('my-typoed-space-name');\n// after\nlet res = await hfSpaces('my-typoed-space-name');\nif (!res.length) res = await hfSpaces('my-typoed'); // broader fallback search","handlingStrategy":"validation","validationCode":"// verify the space exists before querying\nconst exists = await fetch(`https://huggingface.co/api/spaces/${owner}/${name}`)\n  .then(r => r.ok).catch(() => false);\nif (!exists) console.warn(`space ${owner}/${name} not found or private`);","typeGuard":"const hasResults = (res) => Array.isArray(res) && res.length > 0;","tryCatchPattern":"try {\n  const spaces = await hfSpaces(query);\n} catch (e) {\n  if (e.name === 'EmptyResultError' || String(e.message).includes('No matching spaces')) {\n    return { spaces: [], note: 'no match — try broader query' }; // graceful empty\n  }\n  throw e;\n}","preventionTips":["Double-check space author/name spelling","Confirm the space is public (private ones need an HF token)","Loosen search filters when a strict query returns nothing","Handle empty results explicitly in scripts instead of crashing"],"tags":["empty-result","huggingface","search","cli"],"backgroundTag":"empty-result-set","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}