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

  1. Fix the field at the reported path: match the type/name expected by the message's `{inner}` part.
  2. If the data came from an older version, re-run the pipeline to regenerate state instead of deserializing stale data.
  3. For hand-written configs, validate against the current struct definitions (or docs) for the target type shown in `<ty>`.
  4. 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

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


AI-assisted analysis of cocoindex-io/cocoindex@e84aa99b32 (2026-09-08). Data as JSON: /api/errors/dd7e4dda7c716be9. Report an issue: GitHub.