{"record":{"id":"0769944994cf295f","repo":"huggingface/candle","slug":"unsupported-type-for-name-attribute-in","errorCode":null,"errorMessage":"unsupported type {:?} for '{name}' attribute in '{}' for {}","messagePattern":"unsupported type (.+?) for '(.+?)' attribute in '(.+?)' for (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"candle-onnx/src/eval.rs","lineNumber":143,"sourceCode":"}\n\nfn get_attr_<'a>(node: &'a onnx::NodeProto, name: &str) -> Result<&'a onnx::AttributeProto> {\n    match node.attribute.iter().find(|attr| attr.name == name) {\n        None => {\n            bail!(\n                \"cannot find the '{name}' attribute in '{}' for {}\",\n                node.op_type,\n                node.name\n            )\n        }\n        Some(dt) => Ok(dt),\n    }\n}\n\nfn get_attr<'a, T: Attr + ?Sized>(node: &'a onnx::NodeProto, name: &str) -> Result<&'a T> {\n    let attr = get_attr_(node, name)?;\n    if attr.r#type() != T::TYPE {\n        bail!(\n            \"unsupported type {:?} for '{name}' attribute in '{}' for {}\",\n            attr.r#type,\n            node.op_type,\n            node.name\n        )\n    }\n    T::get(attr)\n}\n\nfn get_attr_opt<'a, T: Attr + ?Sized>(\n    node: &'a onnx::NodeProto,\n    name: &str,\n) -> Result<Option<&'a T>> {\n    match node.attribute.iter().find(|attr| attr.name == name) {\n        None => Ok(None),\n        Some(attr) => {\n            if attr.r#type() != T::TYPE {\n                bail!(","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/huggingface/candle/blob/d5fee525bfde3273eb7c9b75fd2bc4937be867ca/candle-onnx/src/eval.rs#L125-L161","documentation":"get_attr fetches a required attribute and then checks its attribute_type against the expected Rust type T::TYPE. When the attribute exists but has a different ONNX type (e.g. INT vs INTS, or FLOAT vs TENSOR), the library bails with the actual type, attribute name, op_type and node name.","triggerScenarios":"Evaluating a model where an op's attribute is stored with a different type than candle-onnx's implementation expects, e.g. reading an INT attribute but the model stores it as FLOAT, or a scalar where a list was expected.","commonSituations":"Exporter quirks writing attributes as the wrong type; opset migrations changing attribute types; hand-edited ONNX files; converter bugs.","solutions":["Inspect the attribute's r#type in the error and fix the model so it matches the expected ONNX attribute type from the operator spec.","Re-export the model with the standard exporter for the target opset.","Convert the attribute in-place with Python onnx (e.g. wrap an int into an ints list).","Ensure the candle-onnx op implementation matches your model's opset."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"let attr = node.attribute.iter().find(|a| a.name == name).ok_or(\"missing\")?;\nassert_eq!(attr.r#type(), expected_type, \"attr '{name}' has type {:?}, expected {:?}\", attr.r#type, expected_type);","typeGuard":"fn attr_is(attr: &onnx::AttributeProto, t: onnx::AttributeType) -> bool {\n    attr.r#type() == t\n}","tryCatchPattern":"match get_attr::<i64>(node, \"axis\") {\n    Ok(v) => v,\n    Err(e) if e.to_string().contains(\"unsupported type\") => return Err(e.into()),\n    Err(e) => return Err(e.into()),\n}","preventionTips":["Check attribute types against the ONNX operator spec when debugging exporter output","Validate the whole model with onnx.checker before Rust inference","Pin exporter versions and opsets known to work with candle-onnx"],"tags":["rust","candle","onnx","attribute","type-mismatch"],"backgroundTag":"onnx-attribute-type-mismatch","analyzedSha":"d5fee525bfde3273eb7c9b75fd2bc4937be867ca","analyzedAt":"2026-09-02T00:15:47.023Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}