{"record":{"id":"3a3af21d21a2c166","repo":"pola-rs/polars","slug":"invalid-offset-format-must-be-00-00-or-timezo","errorCode":null,"errorMessage":"Invalid Offset format (must be [-]00:00) or timezones feature not active","messagePattern":"Invalid Offset format \\(must be \\[-\\]00:00\\) or timezones feature not active","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/polars-json/src/json/write/serialize.rs","lineNumber":481,"sourceCode":"            Ok(parsed_tz) => {\n                let f = move |x: Option<&i64>, buf: &mut Vec<u8>| {\n                    if let Some(x) = x {\n                        let dt_str = timestamp_to_datetime(*x, time_unit, &parsed_tz).to_rfc3339();\n                        write!(buf, \"\\\"{dt_str}\\\"\").unwrap();\n                    } else {\n                        buf.extend_from_slice(b\"null\")\n                    }\n                };\n\n                materialize_serializer(f, array.iter(), offset, take)\n            },\n            _ => {\n                panic!(\"Timezone {tz} is invalid or not supported\");\n            },\n        },\n        #[cfg(not(feature = \"timezones\"))]\n        _ => {\n            panic!(\"Invalid Offset format (must be [-]00:00) or timezones feature not active\");\n        },\n    }\n}\n\npub fn new_serializer<'a>(\n    array: &'a dyn Array,\n    offset: usize,\n    take: usize,\n) -> Box<dyn JsonSerializer<Item = [u8]> + 'a + Send + Sync> {\n    match array.dtype().to_storage() {\n        ArrowDataType::Boolean => {\n            boolean_serializer(array.as_any().downcast_ref().unwrap(), offset, take)\n        },\n        ArrowDataType::Int8 => {\n            primitive_serializer::<i8>(array.as_any().downcast_ref().unwrap(), offset, take)\n        },\n        ArrowDataType::Int16 => {\n            primitive_serializer::<i16>(array.as_any().downcast_ref().unwrap(), offset, take)","sourceCodeStart":463,"sourceCodeEnd":499,"githubUrl":"https://github.com/pola-rs/polars/blob/9b5d73fd00236295624374b075d16b1fe6ec6df9/crates/polars-json/src/json/write/serialize.rs#L463-L499","documentation":"Without the timezones cargo feature, polars-json can only serialize tz-aware timestamps if the zone parses as a fixed offset via parse_offset (\"[-]HH:MM\"); every other tz string on a Timestamp column reaches the cfg(not(feature = \"timezones\")) arm and panics with this combined message. It means: tz-aware column + a zone that is not a bare offset + a build without chrono-tz support.","triggerScenarios":"write_json (JsonWriter/JsonLinesWriter) over Datetime(_, Some(\"Europe/Amsterdam\")) in a build where the timezones feature is disabled. Fixed offsets like \"+02:00\" still work; IANA names do not.","commonSituations":"Minimal-feature Rust services exporting JSON; data ported from python-polars (where the feature is always present) into a trimmed Rust deployment.","solutions":["Enable the timezones feature: polars = { version = \"...\", features = [\"timezones\"] }","Or drop the zone before writing: col(\"ts\").dt().replace_time_zone(None)","Or write Parquet instead, which serializes tz without going through this path"],"exampleFix":"# before\npolars = { version = \"0.4\", default-features = false }\n# write_json on Datetime(_, Some(\"Europe/Amsterdam\")) -> panic\n\n# after\npolars = { version = \"0.4\", default-features = false, features = [\"timezones\"] }\n# or in code: col(\"ts\").dt().replace_time_zone(None)","handlingStrategy":"fallback","validationCode":"fn has_tz_aware(df: &DataFrame) -> bool {\n    df.schema().iter_values().any(|dt| matches!(dt, DataType::Datetime(_, Some(_))))\n}\n// without the `timezones` feature only fixed offsets (+HH:MM) serialize;\n// fallback: strip zones before write_json\n// df.apply(\"ts\", |s| s.datetime().map(|ca| ca.replace_time_zone(None).into_series()))?;","typeGuard":null,"tryCatchPattern":"catch_unwind around write_json merely re-labels the panic; the schema pre-check plus replace_time_zone(None) fallback keeps the export working without the feature.","preventionTips":["Smoke-test a tz-aware JSON export in CI to catch missing features at build time","Keep one canonical polars feature list for all services","If IANA zones are required in JSON output, make timezones a hard build requirement"],"tags":["polars","json","datetime","timezone","cargo-features","serialization","panic"],"backgroundTag":"missing-cargo-feature","analyzedSha":"9b5d73fd00236295624374b075d16b1fe6ec6df9","analyzedAt":"2026-08-19T12:15:06.350Z","contentChangedAt":"2026-08-19T12:15:06.350Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}