{"record":{"id":"d8a834bf51f4d4c4","repo":"earendil-works/pi","slug":"hugging-face-returned-invalid-model-details","errorCode":null,"errorMessage":"Hugging Face returned invalid model details","messagePattern":"Hugging Face returned invalid model details","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/extensions/llama/huggingface.ts","lineNumber":122,"sourceCode":"\t\t\tsort: \"downloads\",\n\t\t\tdirection: \"-1\",\n\t\t\tlimit: \"20\",\n\t\t});\n\t\tconst payload = await this.request(`/api/models?${params}`, signal);\n\t\tif (!Array.isArray(payload)) throw new Error(\"Hugging Face returned invalid search results\");\n\t\treturn payload.flatMap((value) => {\n\t\t\tif (typeof value !== \"object\" || value === null || typeof (value as { id?: unknown }).id !== \"string\")\n\t\t\t\treturn [];\n\t\t\tconst model = value as { id: string; downloads?: unknown };\n\t\t\treturn [{ id: model.id, downloads: typeof model.downloads === \"number\" ? model.downloads : 0 }];\n\t\t});\n\t}\n\n\tasync details(id: string, signal?: AbortSignal): Promise<HuggingFaceModelDetails> {\n\t\tconst encodedId = id.split(\"/\").map(encodeURIComponent).join(\"/\");\n\t\tconst payload = await this.request(`/api/models/${encodedId}?blobs=true`, signal);\n\t\tif (typeof payload !== \"object\" || payload === null) {\n\t\t\tthrow new Error(\"Hugging Face returned invalid model details\");\n\t\t}\n\t\tconst model = payload as { id?: unknown; gated?: unknown; siblings?: unknown };\n\t\tconst sizes = new Map<string, { total: number; complete: boolean }>();\n\t\tif (Array.isArray(model.siblings)) {\n\t\t\tfor (const value of model.siblings) {\n\t\t\t\tif (typeof value !== \"object\" || value === null) continue;\n\t\t\t\tconst file = value as { rfilename?: unknown; size?: unknown };\n\t\t\t\tif (typeof file.rfilename !== \"string\" || !file.rfilename.toLowerCase().endsWith(\".gguf\")) continue;\n\t\t\t\tconst filename = file.rfilename.split(\"/\").at(-1)!;\n\t\t\t\tif (filename.toLowerCase().startsWith(\"mmproj\")) continue;\n\t\t\t\tconst stem = filename.slice(0, -5).replace(SHARD_SUFFIX_PATTERN, \"\");\n\t\t\t\tconst quantization = stem.match(QUANTIZATION_PATTERN)?.[1]?.toUpperCase();\n\t\t\t\tif (!quantization) continue;\n\t\t\t\tconst current = sizes.get(quantization) ?? { total: 0, complete: true };\n\t\t\t\tif (typeof file.size === \"number\") current.total += file.size;\n\t\t\t\telse current.complete = false;\n\t\t\t\tsizes.set(quantization, current);\n\t\t\t}","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/earendil-works/pi/blob/4af9d21d3b4d664e4a29fcabfec85171077248e3/packages/coding-agent/src/extensions/llama/huggingface.ts#L104-L140","documentation":"Error \"Hugging Face returned invalid model details\" thrown in earendil-works/pi.","triggerScenarios":"Thrown at packages/coding-agent/src/extensions/llama/huggingface.ts:122 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4af9d21d3b4d664e4a29fcabfec85171077248e3","analyzedAt":"2026-08-24T13:07:14.692Z","schemaVersion":2},"datasetVersion":"2026-08-24T17:17:21.512Z"}