pola-rs/polars · error
failed to serialize schema hashes file
Error message
failed to serialize schema hashes file
What it means
`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.
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.
Defensive patterns
Strategy: fallback
Validate before calling
cargo check -p polars-plan --bin dsl-schema # verify it compiles with current features
Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "JSON serialization failed", "not JSON serializable", "Failed to serialize": why JSON marshaling errors happen and how to fix them — this error's family across 46 libraries.
Related errors
- failed to serialize the schema
- Timezone is invalid or not supported
- failed to encode spill file for
- Invalid Offset format (must be [-]00:00) or timezones…
- List offset is too large :/
AI-assisted analysis of pola-rs/polars@fe841f959e (2026-09-18).
Data as JSON: /api/errors/f82576741304494a.
Report an issue: GitHub.
Appendix: source
Thrown at crates/polars-plan/src/bin/dsl-schema.rs:131
let mut hashes = serde_json::Map::new();
// Insert the subschemas
if let Some(definitions) = schema.get("$defs") {
if let Some(definitions) = definitions.as_object() {
for (name, def) in definitions {
let mut def = def.to_owned();
def.sort_all_objects();
let schema: &Schema = (&def).try_into().unwrap();
hashes.insert(name.into(), schema_hash(schema).into());
}
assert!(definitions.contains_key("DslPlan"));
}
}
hashes.sort_keys();
serde_json::to_string_pretty(&hashes).expect("failed to serialize schema hashes file")
}
fn schema_hash(schema: &Schema) -> String {
let mut digest = digest_io::IoWrapper(sha2::Sha256::new());
serde_json::to_writer(&mut digest, schema).expect("failed to serialize the schema");
let hash = digest.0.finalize();
hex::encode(hash)
}
}
View on GitHub (pinned to fe841f959e)