{"record":{"id":"b566b23d9121bb1a","repo":"jackwener/OpenCLI","slug":"hf-models","errorCode":null,"errorMessage":"hf models","messagePattern":"hf models","errorType":"exception","errorClass":"EmptyResultError","httpStatus":null,"severity":"error","filePath":"clis/hf/models.js","lineNumber":71,"sourceCode":"                    'Accept': 'application/json',\n                    'User-Agent': 'opencli/1.0 (+https://github.com/jackwener/opencli)',\n                },\n            });\n        } catch (error) {\n            throw new CommandExecutionError(`hf models request failed: ${error?.message || error}`);\n        }\n        if (!resp.ok) {\n            throw new CommandExecutionError(`hf models failed: HTTP ${resp.status}`);\n        }\n        let data;\n        try {\n            data = await resp.json();\n        } catch (error) {\n            throw new CommandExecutionError(`hf models returned malformed JSON: ${error?.message || error}`);\n        }\n        const list = Array.isArray(data) ? data : [];\n        if (list.length === 0) {\n            throw new EmptyResultError('hf models', 'No matching models on huggingface.co.');\n        }\n        return list.slice(0, limit).map((m, i) => {\n            const id = m.id || m.modelId || '';\n            const slashIdx = id.indexOf('/');\n            const author = slashIdx > 0 ? id.slice(0, slashIdx) : '';\n            const tags = Array.isArray(m.tags) ? m.tags.filter(t => !t.startsWith('license:')).slice(0, 10).join(', ') : '';\n            return {\n                rank: i + 1,\n                id,\n                author,\n                pipelineTag: m.pipeline_tag || m.pipelineTag || '',\n                downloads: m.downloads ?? 0,\n                likes: m.likes ?? 0,\n                tags,\n                lastModified: m.lastModified ? String(m.lastModified).slice(0, 10) : '',\n                url: id ? `https://huggingface.co/${id}` : '',\n            };\n        });","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/hf/models.js#L53-L89","documentation":"EmptyResultError('hf models', 'No matching models on huggingface.co.') thrown at clis/hf/models.js:71 when the /api/models response parses successfully but the resulting array is empty (or the body is not an array). It signals that the request succeeded but no models matched, separating empty results from network/HTTP errors.","triggerScenarios":"Running `hf models` with a --search term or --pipeline filter that matches zero models — e.g. --search with a misspelled model name, --search 'orgname/' for a nonexistent owner, or --pipeline with a tag no model uses — while the API itself responds 200 with [].","commonSituations":"Typo in --search ('mistralai/' vs 'mistalai/'); using a pipeline tag not in HF's vocabulary (e.g. 'text-gen' instead of 'text-generation'); searching for a private/gated repo that the public API does not list; combining filters that nothing satisfies.","solutions":["Re-run with a corrected or broader --search value (verify exact owner/model spelling on huggingface.co).","Remove --pipeline or use a valid pipeline tag (e.g. text-generation, image-classification).","Drop all filters (`opencli hf models`) to confirm the API returns data at all.","If HF returns [] even unfiltered, check https://huggingface.co status for an API incident."],"exampleFix":"// before\nopencli hf models --pipeline text-gen\n// after\nopencli hf models --pipeline text-generation","handlingStrategy":"fallback","validationCode":"// Check that a search term actually matches before running the command\nconst r = await fetch('https://huggingface.co/api/models?search=' + encodeURIComponent(term) + '&limit=1');\nconst rows = await r.json();\nif (!Array.isArray(rows) || rows.length === 0) console.warn(`No models match \"${term}\"`);","typeGuard":null,"tryCatchPattern":"try {\n  await run(`hf models --search ${term} --pipeline ${tag}`);\n} catch (e) {\n  if (e.name === 'EmptyResultError') {\n    console.warn('No models matched; falling back to unfiltered listing');\n    await run('hf models');\n  } else throw e;\n}","preventionTips":["Verify pipeline tags against HF's vocabulary (text-generation, image-classification, ...).","Check exact owner/model spellings on huggingface.co before scripting.","Avoid combining filters that may match nothing.","Private/gated repos do not appear in public listing results."],"tags":["empty-result","api","huggingface","filter"],"backgroundTag":"empty-api-result","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}