{"record":{"id":"f82576741304494a","repo":"pola-rs/polars","slug":"failed-to-serialize-schema-hashes-file","errorCode":null,"errorMessage":"failed to serialize schema hashes file","messagePattern":"failed to serialize schema hashes file","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/polars-plan/src/bin/dsl-schema.rs","lineNumber":131,"sourceCode":"        let mut hashes = serde_json::Map::new();\n\n        // Insert the subschemas\n        if let Some(definitions) = schema.get(\"$defs\") {\n            if let Some(definitions) = definitions.as_object() {\n                for (name, def) in definitions {\n                    let mut def = def.to_owned();\n                    def.sort_all_objects();\n                    let schema: &Schema = (&def).try_into().unwrap();\n                    hashes.insert(name.into(), schema_hash(schema).into());\n                }\n\n                assert!(definitions.contains_key(\"DslPlan\"));\n            }\n        }\n\n        hashes.sort_keys();\n\n        serde_json::to_string_pretty(&hashes).expect(\"failed to serialize schema hashes file\")\n    }\n\n    fn schema_hash(schema: &Schema) -> String {\n        let mut digest = digest_io::IoWrapper(sha2::Sha256::new());\n        serde_json::to_writer(&mut digest, schema).expect(\"failed to serialize the schema\");\n        let hash = digest.0.finalize();\n        hex::encode(hash)\n    }\n}\n","sourceCodeStart":113,"sourceCodeEnd":141,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/crates/polars-plan/src/bin/dsl-schema.rs#L113-L141","documentation":"`current_schema_hashes` collects per-type schema hashes, sorts the keys, and serializes the map with `serde_json::to_string_pretty`, expecting success. A panic here means the hash map itself could not be serialized — practically only via an underlying per-schema serialization failure surfaced through `schema_hash`, or a bug/mismatched serde feature set.","triggerScenarios":"A Schema whose serde serialization fails during hashing (e.g. data serde_json cannot represent), or mismatched serde/serde_json feature configuration while compiling polars-plan with the dsl-schema bin.","commonSituations":"Building with unusual feature combinations that alter Schema serde behavior; a newly added plan node whose Schema contains non-JSON-serializable data; polars version where serialization was broken.","solutions":["Update polars to the latest patch — this indicates a serialization bug in a Schema type.","Rebuild with the default/recommended feature set to rule out feature-induced serde differences.","File an upstream issue with the feature flags used; the hash function's inner `to_writer` failure will name the offending schema."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"cargo check -p polars-plan --bin dsl-schema  # verify it compiles with current features","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep polars up to date; this panic signals an upstream serialization bug.","Stick to default/recommended feature sets for the dsl-schema bin.","Pin a known-good polars version in CI until an upstream fix lands."],"tags":["serialization","json","hashing","panic"],"backgroundTag":"json-serialization-failed","analyzedSha":"fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e","analyzedAt":"2026-09-18T22:14:11.667Z","contentChangedAt":"2026-09-18T22:14:11.667Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}