{"record":{"id":"cc530cb924ebd233","repo":"huggingface/candle","slug":"missing-input","errorCode":null,"errorMessage":"missing input {}","messagePattern":"missing input (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"candle-onnx/src/eval.rs","lineNumber":273,"sourceCode":"        let tensor = get_tensor(t, t.name.as_str())?;\n        values.insert(t.name.to_string(), tensor);\n    }\n    for input in graph.input.iter() {\n        let input_type = match &input.r#type {\n            Some(input_type) => input_type,\n            None => continue,\n        };\n        let input_type = match &input_type.value {\n            Some(input_type) => input_type,\n            None => continue,\n        };\n        let tensor_type = match input_type {\n            onnx::type_proto::Value::TensorType(tt) => tt,\n            _ => continue,\n        };\n\n        let tensor = match values.get(&input.name) {\n            None => bail!(\"missing input {}\", input.name),\n            Some(tensor) => tensor,\n        };\n        let dt = match DataType::try_from(tensor_type.elem_type) {\n            Ok(dt) => match dtype(dt) {\n                Some(dt) => dt,\n                None => {\n                    bail!(\"unsupported 'value' data-type {dt:?} for {}\", input.name)\n                }\n            },\n            type_ => bail!(\"unsupported input type {type_:?}\"),\n        };\n        match &tensor_type.shape {\n            None => continue,\n            Some(shape) => {\n                if shape.dim.len() != tensor.rank() {\n                    bail!(\n                        \"unexpected rank for {}, got {:?}, expected {:?}\",\n                        input.name,","sourceCodeStart":255,"sourceCodeEnd":291,"githubUrl":"https://github.com/huggingface/candle/blob/d5fee525bfde3273eb7c9b75fd2bc4937be867ca/candle-onnx/src/eval.rs#L255-L291","documentation":"Before running the graph, simple_eval_ iterates graph.input and looks up each declared input in the user-supplied values HashMap. If a name declared as a model input is absent from the inputs map, evaluation cannot proceed and this error is thrown. Input names in ONNX are exact-match strings.","triggerScenarios":"simple_eval called with an inputs HashMap missing one or more names declared in model.graph.input — typically a typo'd key, a case mismatch, or forgetting a required input (ONNX models have multiple inputs).","commonSituations":"Multi-input models (e.g. tokens + attention_mask); inputs accidentally fed only as initializers; renaming of inputs between exporter versions; passing input named 'x' when the model declares 'input' or 'input_ids'.","solutions":["Print model.graph.input names and ensure every one has a matching key in the inputs HashMap (exact string match, case-sensitive).","Check whether the missing name is actually an initializer/parameter rather than a runtime input; those must not be supplied.","Use the model's exported input signature from the exporter (e.g. torch.onnx.export input_names) to build the map.","Handle the error and report which input name is required in your app's validation layer."],"exampleFix":"// before\nlet mut inputs = HashMap::new();\ninputs.insert(\"x\".to_string(), xs);\n// after\nlet mut inputs = HashMap::new();\ninputs.insert(\"input\".to_string(), xs); // name from model.graph.input\ninputs.insert(\"attention_mask\".to_string(), mask);","handlingStrategy":"validation","validationCode":"fn missing_inputs(model: &onnx::ModelProto, inputs: &HashMap<String, Value>) -> Vec<String> {\n    model.graph.as_ref().map_or(vec![], |g| g.input.iter()\n        .filter(|i| !inputs.contains_key(&i.name))\n        .map(|i| i.name.clone()).collect())\n}","typeGuard":null,"tryCatchPattern":"if let Err(e) = simple_eval(&model, inputs) {\n    if let Some(name) = e.to_string().strip_prefix(\"missing input \") {\n        anyhow::bail!(\"model requires input '{name}' — check spelling/casing\");\n    }\n    return Err(e.into());\n}","preventionTips":["Log model.graph.input names at startup and build the input map from them","Remember ONNX names are exact, case-sensitive strings","Multi-input models: supply every declared input","Initializers are not runtime inputs — do not add or skip them based on that assumption"],"tags":["onnx","input-validation","missing-value","eval"],"backgroundTag":"missing-required-input","analyzedSha":"d5fee525bfde3273eb7c9b75fd2bc4937be867ca","analyzedAt":"2026-09-02T00:15:47.023Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}