tracel-ai/burn · error
This should never be called since next_key_seed always retur
Error message
This should never be called since next_key_seed always returns None
What it means
This panic is a defensive invariant check, not a real deserialization path. The map access implementation in burn-store's nested de always returns None from next_key_seed, so next_value_seed should never be invoked; if it is, the runtime state is inconsistent and the code deliberately panics.
Source
Thrown at crates/burn-store/src/nested/de.rs:1008
DefaultMapAccess
}
}
impl<'de> MapAccess<'de> for DefaultMapAccess {
type Error = Error;
fn next_key_seed<T>(&mut self, _seed: T) -> Result<Option<T::Value>, Self::Error>
where
T: DeserializeSeed<'de>,
{
Ok(None)
}
fn next_value_seed<T>(&mut self, _seed: T) -> Result<T::Value, Self::Error>
where
T: DeserializeSeed<'de>,
{
unimplemented!("This should never be called since next_key_seed always returns None")
}
fn size_hint(&self) -> Option<usize> {
None
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::nested::adapter::DefaultAdapter;
use serde::Deserialize;
#[derive(Debug, Deserialize, PartialEq)]
struct AllScalars {
b: bool,
i16_val: i16,
i32_val: i32,View on GitHub (pinned to d16f7ba2ed)
Solutions
- Fix the custom Deserialize/seed logic to stop when next_key_seed returns None
- Only call next_value_seed after next_key_seed returned Some
- Update burn-store to a version with corrected map access logic
- Report the mismatch if it comes from the library's own deserializer
Example fix
// before
while map.next_key_seed(k)? .is_some() || true {
map.next_value_seed(v)?;
}
// after
while let Some(_) = map.next_key_seed(k)? {
map.next_value_seed(v)?;
} Defensive patterns
Strategy: try-catch
Try / catch
let r = std::panic::catch_unwind(|| T::deserialize(nested));
if r.is_err() {
// invariant broken: check map-access loop stops at next_key_seed == None
return Err(Error::MalformedNestedValue);
} Prevention
- In custom Deserialize impls, always stop iterating when next_key_seed returns None
- Only call next_value_seed after a successful next_key_seed
- Keep burn-store updated; this stub protects against internal misuse
When it happens
Trigger: A Deserialize implementation manually drives map access and calls next_value_seed after next_key_seed returned None, or an adapter bug causes value extraction without a key.
Common situations: Custom Deserialize/DeserializeSeed implementations that ignore next_key_seed's None and unconditionally call next_value_seed; rarely hit by end users directly.
Related errors
- deserialize_any is not implemented
- deserialize_i8 is not implemented
- deserialize_u32 is not implemented
- deserialize_char is not implemented
- deserialize_bytes is not implemented
AI-assisted analysis of tracel-ai/burn@d16f7ba2ed (2026-09-05).
Data as JSON: /api/errors/b82e600086703ba6.
Report an issue: GitHub.