{"record":{"id":"37971ffdc463c3c7","repo":"tracel-ai/burn","slug":"deserialize-unit-is-not-implemented","errorCode":null,"errorMessage":"deserialize_unit is not implemented","messagePattern":"deserialize_unit is not implemented","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-store/src/nested/de.rs","lineNumber":301,"sourceCode":"    fn deserialize_option<V>(self, visitor: V) -> Result<V::Value, Self::Error>\n    where\n        V: Visitor<'de>,\n    {\n        if let Some(value) = self.value {\n            visitor.visit_some(Deserializer::<A>::new(\n                value,\n                self.default_for_missing_fields,\n            ))\n        } else {\n            visitor.visit_none()\n        }\n    }\n\n    fn deserialize_unit<V>(self, _visitor: V) -> Result<V::Value, Self::Error>\n    where\n        V: Visitor<'de>,\n    {\n        unimplemented!(\"deserialize_unit is not implemented\")\n    }\n\n    fn deserialize_unit_struct<V>(\n        self,\n        _name: &'static str,\n        _visitor: V,\n    ) -> Result<V::Value, Self::Error>\n    where\n        V: Visitor<'de>,\n    {\n        unimplemented!(\"deserialize_unit_struct is not implemented\")\n    }\n\n    fn deserialize_newtype_struct<V>(\n        self,\n        _name: &'static str,\n        visitor: V,\n    ) -> Result<V::Value, Self::Error>","sourceCodeStart":283,"sourceCodeEnd":319,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-store/src/nested/de.rs#L283-L319","documentation":"The nested-value deserializer does not implement serde's `deserialize_unit` and panics instead. Unit (`()`) and unit-like placeholder fields are not representable in NestedValue, so any record type containing them routes to this deliberate unimplemented!() during load.","triggerScenarios":"Loading a Burn record whose struct contains a field of type `()` (unit), or a unit placeholder produced by some Deserialize impls, via the nested-value recorder path.","commonSituations":"Record items with phantoms/unit markers; macro-generated code inserting () fields; type changes across Burn versions that turned an optional field into a unit placeholder.","solutions":["Remove the unit field from the record struct — it carries no data and cannot round-trip.","Replace () with Option<()> via a custom deserializer, or better, drop it and use a type-level marker (PhantomData handled outside serde).","Regenerate the checkpoint so it matches the supported schema.","If a macro generates the field, adjust the macro or the underlying type definition."],"exampleFix":"// before\nstruct Item { marker: () } // -> deserialize_unit panic\n// after\nstruct Item { _marker: core::marker::PhantomData<()> } // not serialized","handlingStrategy":"validation","validationCode":"// Audit record structs for unit fields; drop them:\n// struct Item { data: TensorData }  // no `marker: ()` fields\n// PhantomData is fine because serde skips it via derived impls configured with #[serde(skip)]","typeGuard":null,"tryCatchPattern":"let record = std::panic::catch_unwind(|| from_nested_value::<MyItem>(value.clone()))\n    .map_err(|_| \"record contains unit (): not supported by nested deserializer\");","preventionTips":["Never put () fields in serializable record structs.","Use PhantomData (serde-skipped) for type-level markers.","Round-trip test record types when refactoring."],"tags":["rust","serde","deserialization","burn","panic","unit"],"backgroundTag":"unsupported-deserializer-method","analyzedSha":"d16f7ba2ed0d41408189384044cc886fb4c8f957","analyzedAt":"2026-09-05T13:19:14.260Z","contentChangedAt":"2026-09-05T13:19:14.260Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}