cocoindex-io/cocoindex · error
while deserializing `{full_path}`: {inner}
Error message
while deserializing `{full_path}`: {inner} What it means
This is a deserialization error wrapper: serde failed to convert a JSON/value into type T, and cocoindex uses serde_path_to_error to report the exact field path (e.g. `<TargetConfig>.spec.regex`) plus the underlying serde message. It tells you precisely where in the structure the data did not match the expected schema.
Source
Thrown at rust/utils/src/deser.rs:15
use anyhow::{Result, anyhow};
use serde::de::DeserializeOwned;
fn format_serde_path_err<T, E: std::fmt::Display>(
err: serde_path_to_error::Error<E>,
) -> anyhow::Error {
let ty = std::any::type_name::<T>().replace("::", ".");
let path = err.path();
let full_path = if path.iter().next().is_none() {
format!("<{ty}>")
} else {
format!("<{ty}>.{path}")
};
let inner = err.into_inner();
anyhow!("while deserializing `{full_path}`: {inner}")
}
pub fn from_json_value<T: DeserializeOwned>(value: serde_json::Value) -> Result<T> {
serde_path_to_error::deserialize::<_, T>(value).map_err(format_serde_path_err::<T, _>)
}
pub fn from_json_str<T: DeserializeOwned>(s: &str) -> Result<T> {
let mut de = serde_json::Deserializer::from_str(s);
serde_path_to_error::deserialize::<_, T>(&mut de).map_err(format_serde_path_err::<T, _>)
}
pub fn from_msgpack_slice<'a, T: serde::Deserialize<'a>>(data: &'a [u8]) -> Result<T> {
let mut de = rmp_serde::Deserializer::from_read_ref(data);
serde_path_to_error::deserialize::<_, T>(&mut de).map_err(format_serde_path_err::<T, _>)
}
View on GitHub (pinned to e84aa99b32)
Solutions
- Fix the field at the reported path: match the type/name expected by the message's `{inner}` part.
- If the data came from an older version, re-run the pipeline to regenerate state instead of deserializing stale data.
- For hand-written configs, validate against the current struct definitions (or docs) for the target type shown in `<ty>`.
- Clear/recreate the corrupted persisted state entry if it cannot be migrated.
Example fix
// before
from_json_value::<Config>(json!({"chunks": 3})) // expects chunk_size: u64
// after
from_json_value::<Config>(json!({"chunk_size": 3})) Defensive patterns
Strategy: validation
Validate before calling
// validate before committing state
let cfg: Config = serde_json::from_value(value.clone())
.map_err(|e| anyhow!("config shape mismatch: {e}"))?; Try / catch
// match on the path-aware error
match deser::from_json_value::<Config>(value) {
Ok(cfg) => apply(cfg),
Err(e) => {
eprintln!("{e:#}"); // shows field path + serde reason
// regenerate or migrate the stale state
}
} Prevention
- Keep serialized state and struct definitions in the same version; migrate on upgrade.
- Never hand-edit persisted JSON/state; regenerate via the pipeline.
- Round-trip test new config structs with serde to catch schema drift.
When it happens
Trigger: Any code path using utils::deser::from_json_value / from_str (loading saved state, target configs, or exported specs) where a field is missing, has the wrong type, or an untagged enum variant fails to match.
Common situations: Reading an LMDB/database state written by an older cocoindex version whose schema has since changed (enum variant renamed); hand-edited JSON config with a type typo; passing a serde_json::Value built by another tool with different field names.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- Unsupported record type: {self.record_type}
- Unknown routing byte: {routing_byte:#x} ({_error_context()})
- Primary key column '{pk}' not found in columns: {list(self.c
- Unexpected column subkey format: {sub_key!r}, expected to st
- VectorSchemaProvider is required for NumPy ndarray type.
AI-assisted analysis of cocoindex-io/cocoindex@e84aa99b32 (2026-09-08).
Data as JSON: /api/errors/dd7e4dda7c716be9.
Report an issue: GitHub.