huggingface/candle · error
missing input {}
Error message
missing input {} What it means
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.
Source
Thrown at candle-onnx/src/eval.rs:273
let tensor = get_tensor(t, t.name.as_str())?;
values.insert(t.name.to_string(), tensor);
}
for input in graph.input.iter() {
let input_type = match &input.r#type {
Some(input_type) => input_type,
None => continue,
};
let input_type = match &input_type.value {
Some(input_type) => input_type,
None => continue,
};
let tensor_type = match input_type {
onnx::type_proto::Value::TensorType(tt) => tt,
_ => continue,
};
let tensor = match values.get(&input.name) {
None => bail!("missing input {}", input.name),
Some(tensor) => tensor,
};
let dt = match DataType::try_from(tensor_type.elem_type) {
Ok(dt) => match dtype(dt) {
Some(dt) => dt,
None => {
bail!("unsupported 'value' data-type {dt:?} for {}", input.name)
}
},
type_ => bail!("unsupported input type {type_:?}"),
};
match &tensor_type.shape {
None => continue,
Some(shape) => {
if shape.dim.len() != tensor.rank() {
bail!(
"unexpected rank for {}, got {:?}, expected {:?}",
input.name,View on GitHub (pinned to d5fee525bf)
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.
Example fix
// before
let mut inputs = HashMap::new();
inputs.insert("x".to_string(), xs);
// after
let mut inputs = HashMap::new();
inputs.insert("input".to_string(), xs); // name from model.graph.input
inputs.insert("attention_mask".to_string(), mask); Defensive patterns
Strategy: validation
Validate before calling
fn missing_inputs(model: &onnx::ModelProto, inputs: &HashMap<String, Value>) -> Vec<String> {
model.graph.as_ref().map_or(vec![], |g| g.input.iter()
.filter(|i| !inputs.contains_key(&i.name))
.map(|i| i.name.clone()).collect())
} Try / catch
if let Err(e) = simple_eval(&model, inputs) {
if let Some(name) = e.to_string().strip_prefix("missing input ") {
anyhow::bail!("model requires input '{name}' — check spelling/casing");
}
return Err(e.into());
} Prevention
- 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
When it happens
Trigger: 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).
Common situations: 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'.
Related errors
- unexpected rank for {}, got {:?}, expected {:?}
- unexpected dtype for {}, got {:?}, expected {dt:?}
- cannot find {input_name} for op '{}'
- unsupported 'value' data-type {dt:?} for {}
- unsupported input type {type_:?}
AI-assisted analysis of huggingface/candle@d5fee525bf (2026-09-02).
Data as JSON: /api/errors/cc530cb924ebd233.
Report an issue: GitHub.