{"record":{"id":"ac14fd2af83368ab","repo":"ruvnet/ruflo","slug":"unknown-gguf-array-element-type-elemtype","errorCode":null,"errorMessage":"Unknown GGUF array element type: ${elemType}","messagePattern":"Unknown GGUF array element type: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/cli/src/appliance/gguf-engine.ts","lineNumber":136,"sourceCode":"    case GgufValueType.BOOL:    return reader.readBool();\n    case GgufValueType.STRING:  return reader.readString();\n    case GgufValueType.UINT64:  return Number(reader.readU64());\n    case GgufValueType.INT64:   return Number(reader.readI64());\n    case GgufValueType.FLOAT64: return reader.readF64();\n    default: return undefined;\n  }\n}\n\n/** Read a single GGUF typed value (scalar or array) from the buffer. */\nfunction readGgufValue(reader: BufferReader): unknown {\n  const valueType = reader.readU32();\n  if (valueType === GgufValueType.ARRAY) {\n    const elemType = reader.readU32();\n    const len = reader.readU64AsNumber();\n    const arr: unknown[] = [];\n    for (let i = 0; i < len; i++) {\n      const v = readScalar(reader, elemType);\n      if (v === undefined) throw new Error(`Unknown GGUF array element type: ${elemType}`);\n      arr.push(v);\n    }\n    return arr;\n  }\n  const v = readScalar(reader, valueType);\n  if (v === undefined) throw new Error(`Unknown GGUF value type: ${valueType}`);\n  return v;\n}\n\n// ── GGUF Header Parsing ─────────────────────────────────────\n\n/**\n * Parse the header and metadata from a GGUF file without loading tensors.\n * Reads only the first 256 KB of the file.\n */\nexport async function parseGgufHeader(path: string): Promise<GgufMetadata> {\n  const fileInfo = await fsStat(path);\n  const readSize = Math.min(fileInfo.size, 256 * 1024);","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/ruvnet/ruflo/blob/6b01dc5a687b26b3e218f796de45ec51f8fa9e8c/v3/@claude-flow/cli/src/appliance/gguf-engine.ts#L118-L154","documentation":"Thrown while reading a GGUF array value: the element type code (readGgufValue encountered valueType === ARRAY, then read the element type as elemType) is not one of the cases handled by readScalar, which returns undefined for unknown types. This indicates either an unknown/extended GGUF value type or buffer corruption causing a garbage type code.","triggerScenarios":"Parsing a GGUF whose metadata contains an array whose element type is outside the implemented GgufValueType set (e.g. a newer spec type the parser does not yet support), or a corrupted buffer where the element-type u32 is random.","commonSituations":"A GGUF produced by tooling that emits a value type this parser does not recognize (spec drift / newer GGUF revision); file corruption from an interrupted download; reading a non-GGUF file whose bytes happen to pass the magic check.","solutions":["Confirm the file parses with a reference GGUF reader (llama.cpp) to distinguish corruption from an unsupported type.","If the type is legitimate but unsupported, extend readScalar's switch to handle the new GgufValueType and add it to the enum.","Re-download the model to rule out transfer corruption.","For non-critical metadata, the parseGgufBuffer KV loop already try/catches per-entry, so partial metadata can still be usable if the unknown array is in a non-essential key."],"exampleFix":"// before\n// readScalar returns undefined for unsupported elemType\n\n// after\nfunction readScalar(reader: BufferReader, t: number): unknown {\n  switch (t) {\n    case GgufValueType.UINT8: return reader.readU8();\n    // ... existing cases ...\n    case NEW_TYPE_BOOL: return reader.readBool();\n    default: return undefined;\n  }\n}","handlingStrategy":"fallback","validationCode":"// No pre-check is possible for an unknown type; instead validate the file with a\n// reference reader and, if a known-unsupported type is expected, extend readScalar.","typeGuard":"function isKnownValueType(t: number): boolean {\n  return Object.values(GgufValueType).includes(t as GgufValueType);\n}","tryCatchPattern":"try {\n  return await parseGgufHeader(path);\n} catch (e) {\n  if (e instanceof Error && /Unknown GGUF array element type/.test(e.message)) {\n    logger.warn({ path }, 'unsupported array type; some metadata unavailable');\n  }\n  throw e;\n}","preventionTips":["Use GGUF files produced by current tooling.","Extend readScalar when adopting a newer GGUF spec.","Validate files with llama.cpp first.","Re-download to rule out corruption."],"tags":["gguf","binary-parsing","file-format","appliance"],"backgroundTag":null,"analyzedSha":"6b01dc5a687b26b3e218f796de45ec51f8fa9e8c","analyzedAt":"2026-08-12T13:20:50.148Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}