{"record":{"id":"1f1395288513fc21","repo":"huggingface/candle","slug":"not-a-vec-v","errorCode":null,"errorMessage":"not a vec {v:?}","messagePattern":"not a vec (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"candle-core/src/quantized/gguf_file.rs","lineNumber":308,"sourceCode":"\n    pub fn to_f64(&self) -> Result<f64> {\n        match self {\n            Self::F64(v) => Ok(*v),\n            v => crate::bail!(\"not a f64 {v:?}\"),\n        }\n    }\n\n    pub fn to_bool(&self) -> Result<bool> {\n        match self {\n            Self::Bool(v) => Ok(*v),\n            v => crate::bail!(\"not a bool {v:?}\"),\n        }\n    }\n\n    pub fn to_vec(&self) -> Result<&Vec<Value>> {\n        match self {\n            Self::Array(v) => Ok(v),\n            v => crate::bail!(\"not a vec {v:?}\"),\n        }\n    }\n\n    pub fn to_string(&self) -> Result<&String> {\n        match self {\n            Self::String(v) => Ok(v),\n            v => crate::bail!(\"not a string {v:?}\"),\n        }\n    }\n\n    fn read<R: std::io::Read + std::io::Seek>(\n        reader: &mut R,\n        value_type: ValueType,\n        magic: &VersionedMagic,\n        depth: usize,\n        file_size: u64,\n    ) -> Result<Self> {\n        if depth > GGUF_MAX_VALUE_DEPTH {","sourceCodeStart":290,"sourceCodeEnd":326,"githubUrl":"https://github.com/huggingface/candle/blob/d5fee525bfde3273eb7c9b75fd2bc4937be867ca/candle-core/src/quantized/gguf_file.rs#L290-L326","documentation":"Value::to_vec throws this when the metadata value is not an Array. Only Value::Array variants can be borrowed as a list of nested values; scalar or string values bail with this message, printing the actual variant. It signals you tried to iterate a non-list GGUF entry.","triggerScenarios":"Calling .to_vec() on a scalar metadata entry such as 'tokenizer.ggml.model' (a String) or a numeric field, when the intent was a list like 'tokenizer.ggml.tokens'.","commonSituations":"Confusing similarly named GGUF keys (singular vs .tokens/.scores/.merges plural forms); files where a list field was collapsed to a single scalar by the writer; iterating all Content metadata and assuming every value is an array.","solutions":["Call the accessor matching the printed variant (to_string for strings, to_u32 for numbers, ...).","Check the Content metadata map for the correct list key name (e.g. tokenizer.ggml.tokens vs tokenizer.ggml.model).","Match on Value::Array explicitly and skip/handle scalar entries when scanning all metadata.","Rewrite the GGUF file with the field as an Array if it was wrongly written as a scalar."],"exampleFix":"// before\nlet tokens = content.metadata.get(\"tokenizer.ggml.tokens\").unwrap().to_vec()?;\n// after\nlet tokens = match content.metadata.get(\"tokenizer.ggml.tokens\") {\n    Some(gguf_file::Value::Array(vs)) => vs,\n    Some(other) => candle_core::bail!(\"tokens is not an array: {other:?}\"),\n    None => candle_core::bail!(\"missing tokenizer.ggml.tokens\"),\n};","handlingStrategy":"type-guard","validationCode":"fn is_array(v: &gguf_file::Value) -> bool { matches!(v, gguf_file::Value::Array(_)) }\nif !is_array(value) { bail!(\"expected array metadata, got {value:?}\"); }","typeGuard":"fn as_array(v: &gguf_file::Value) -> Option<&Vec<gguf_file::Value>> {\n    if let gguf_file::Value::Array(vs) = v { Some(vs) } else { None }\n}","tryCatchPattern":"let arr = match value.to_vec() {\n    Ok(vs) => vs,\n    Err(e) => { eprintln!(\"not an array: {e}\"); return Ok(Vec::new()); }\n};","preventionTips":["Verify GGUF key names (plural .tokens/.merges/.scores) before reading","Handle scalar values when iterating all metadata entries","Validate required list fields exist and are arrays right after Content::read","Compare against a known-good file from the same converter"],"tags":["candle","gguf","type-mismatch"],"backgroundTag":"unexpected-value-type","analyzedSha":"d5fee525bfde3273eb7c9b75fd2bc4937be867ca","analyzedAt":"2026-09-02T00:15:47.023Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}