databendlabs/databend · error

Unimplemented serialize DataSourceMeta

Error message

Unimplemented serialize DataSourceMeta

What it means

`DataSourceWithMeta<T>` deliberately implements `serde::Serialize` as an `unimplemented!()` stub because reading sources with their meta are runtime-only constructs that are never sent over the wire. Serializing such a value panics with 'Unimplemented serialize DataSourceMeta'.

Solutions

  1. Exclude the field from serialization (`#[serde(skip)]`) or restructure so only the inner meta is stored
  2. Serialize the contained data source/meta separately using its own serializable types
  3. If truly needed, implement serialize by delegating to the inner T's Serialize impl

Example fix

// before
struct Checkpoint {
    source: DataSourceWithMeta<FuseSegmentReader>,
}
// after
#[derive(Serialize)]
struct Checkpoint {
    #[serde(skip)]
    source: DataSourceWithMeta<FuseSegmentReader>,
}
Defensive patterns

Strategy: type-guard

Validate before calling

let serializable = !std::any::TypeId::of::<T>().needs_datasource_wrapper(); // keep DataSourceWithMeta out of Serialize structs

Type guard

fn contains_datasource_with_meta<S: Serialize>(v: &S) -> bool { /* compile-time: ensure no DataSourceWithMeta field via serde(skip) */ false }

Try / catch

std::panic::catch_unwind(AssertUnwindSafe(|| serde_json::to_value(&state)))
  .map_err(|_| "state contains non-serializable DataSourceWithMeta")

Prevention

When it happens

Trigger: Any serde serialization of a `DataSourceWithMeta` value, e.g. embedding one in a struct sent through serde_json, tracing payload capture, or a cache that serializes arbitrary pipeline state.

Common situations: Adding a DataSourceWithMeta field to a serializable struct; debug logging with serde capture enabled; migrating pipeline state to a serialized checkpoint format.

Related errors


AI-assisted analysis of databendlabs/databend@288d84d76e (2026-09-11). Data as JSON: /api/errors/31361560657b7ed3. Report an issue: GitHub.

Appendix: source

Thrown at src/query/storages/fuse/src/operations/read/data_source_with_meta.rs:60

            );
        }

        Box::new(DataSourceWithMeta { meta: part, data })
    }
}

impl<T> Debug for DataSourceWithMeta<T> {
    fn fmt(&self, f: &mut Formatter) -> std::fmt::Result {
        f.debug_struct("DataSourceWithMeta")
            .field("meta", &self.meta)
            .finish()
    }
}

impl<T> serde::Serialize for DataSourceWithMeta<T> {
    fn serialize<S>(&self, _: S) -> std::result::Result<S::Ok, S::Error>
    where S: Serializer {
        unimplemented!("Unimplemented serialize DataSourceMeta")
    }
}

impl<'de, T> serde::Deserialize<'de> for DataSourceWithMeta<T> {
    fn deserialize<D>(_: D) -> std::result::Result<Self, D::Error>
    where D: Deserializer<'de> {
        unimplemented!("Unimplemented deserialize DataSourceMeta")
    }
}

View on GitHub (pinned to 288d84d76e)