diesel-rs/diesel · error
Field not found
Error message
Field not found
What it means
Runtime panic from the Index<&str> impl for DynamicRow<NamedField<I>> in diesel_dynamic_schema. The row is indexed by field name via a linear search over the named values; when no field's name equals the requested key the Option is unwrapped with expect, so a typo'd or absent column name panics with this generic sentinel. Fix: index with a name that exists in the row, or look up the field fallibly before indexing.
Solutions
- Use an existing field name from the row
- Inspect the row's field list before indexing
- Add the missing field to the dynamic schema
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at diesel_dynamic_schema/src/dynamic_value.rs:530 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of diesel-rs/diesel@6fa6ed01b2 (2026-09-07).
Data as JSON: /api/errors/44a853ed73d9c6ca.
Report an issue: GitHub.
Appendix: source
Thrown at diesel_dynamic_schema/src/dynamic_value.rs:530
&self.values[index]
}
}
impl<I> IndexMut<usize> for DynamicRow<I> {
fn index_mut(&mut self, index: usize) -> &mut Self::Output {
&mut self.values[index]
}
}
impl<'a, I> Index<&'a str> for DynamicRow<NamedField<I>> {
type Output = I;
fn index(&self, field_name: &'a str) -> &Self::Output {
self.values
.iter()
.find(|f| f.name == field_name)
.map(|f| &f.value)
.expect("Field not found")
}
}
impl<'a, I> IndexMut<&'a str> for DynamicRow<NamedField<I>> {
fn index_mut(&mut self, field_name: &'a str) -> &mut Self::Output {
self.values
.iter_mut()
.find(|f| f.name == field_name)
.map(|f| &mut f.value)
.expect("Field not found")
}
}
impl<'a, I> Index<&'a String> for DynamicRow<NamedField<I>> {
type Output = I;
fn index(&self, field_name: &'a String) -> &Self::Output {
self.index(field_name as &str)View on GitHub (pinned to 6fa6ed01b2)