{"record":{"id":"31361560657b7ed3","repo":"databendlabs/databend","slug":"unimplemented-serialize-datasourcemeta","errorCode":null,"errorMessage":"Unimplemented serialize DataSourceMeta","messagePattern":"Unimplemented serialize DataSourceMeta","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/query/storages/fuse/src/operations/read/data_source_with_meta.rs","lineNumber":60,"sourceCode":"            );\n        }\n\n        Box::new(DataSourceWithMeta { meta: part, data })\n    }\n}\n\nimpl<T> Debug for DataSourceWithMeta<T> {\n    fn fmt(&self, f: &mut Formatter) -> std::fmt::Result {\n        f.debug_struct(\"DataSourceWithMeta\")\n            .field(\"meta\", &self.meta)\n            .finish()\n    }\n}\n\nimpl<T> serde::Serialize for DataSourceWithMeta<T> {\n    fn serialize<S>(&self, _: S) -> std::result::Result<S::Ok, S::Error>\n    where S: Serializer {\n        unimplemented!(\"Unimplemented serialize DataSourceMeta\")\n    }\n}\n\nimpl<'de, T> serde::Deserialize<'de> for DataSourceWithMeta<T> {\n    fn deserialize<D>(_: D) -> std::result::Result<Self, D::Error>\n    where D: Deserializer<'de> {\n        unimplemented!(\"Unimplemented deserialize DataSourceMeta\")\n    }\n}\n","sourceCodeStart":42,"sourceCodeEnd":70,"githubUrl":"https://github.com/databendlabs/databend/blob/288d84d76e20a2f8f7173bda9691eb6ece301aa9/src/query/storages/fuse/src/operations/read/data_source_with_meta.rs#L42-L70","documentation":"`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'.","triggerScenarios":"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.","commonSituations":"Adding a DataSourceWithMeta field to a serializable struct; debug logging with serde capture enabled; migrating pipeline state to a serialized checkpoint format.","solutions":["Exclude the field from serialization (`#[serde(skip)]`) or restructure so only the inner meta is stored","Serialize the contained data source/meta separately using its own serializable types","If truly needed, implement serialize by delegating to the inner T's Serialize impl"],"exampleFix":"// before\nstruct Checkpoint {\n    source: DataSourceWithMeta<FuseSegmentReader>,\n}\n// after\n#[derive(Serialize)]\nstruct Checkpoint {\n    #[serde(skip)]\n    source: DataSourceWithMeta<FuseSegmentReader>,\n}","handlingStrategy":"type-guard","validationCode":"let serializable = !std::any::TypeId::of::<T>().needs_datasource_wrapper(); // keep DataSourceWithMeta out of Serialize structs","typeGuard":"fn contains_datasource_with_meta<S: Serialize>(v: &S) -> bool { /* compile-time: ensure no DataSourceWithMeta field via serde(skip) */ false }","tryCatchPattern":"std::panic::catch_unwind(AssertUnwindSafe(|| serde_json::to_value(&state)))\n  .map_err(|_| \"state contains non-serializable DataSourceWithMeta\")","preventionTips":["Never add DataSourceWithMeta fields to serde-serializable structs; use #[serde(skip)]","Serialize only the inner meta types (SegmentInfo, TableMeta) which have real serde impls","Audit derived Serialize impls after adding read-pipeline fields"],"tags":["rust","serde","serialization","unimplemented"],"backgroundTag":"method-not-implemented","analyzedSha":"288d84d76e20a2f8f7173bda9691eb6ece301aa9","analyzedAt":"2026-09-11T11:29:36.208Z","contentChangedAt":"2026-09-11T11:29:36.208Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}