{"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/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/crates/polars-json/src/json/write/serialize.rs#L463-L499","documentation":"With the 'timezones' feature disabled, timestamp_tz_serializer has no fallback for any timezone string other than a fixed '[-]HH:MM' offset and panics with this message. It signals either a malformed offset string or a build lacking timezone support.","triggerScenarios":"Serializing a Timestamp array whose timezone is not a parseable fixed offset like '+02:00'/'-05:30' while polars is compiled without feature = \"timezones\" — e.g. writing JSON for a column with tz 'Europe/Paris' on a non-timezones build.","commonSituations":"Minimal polars feature sets (no 'timezones') handling data produced with IANA timezones; typos in offset strings like '+0200' or 'UTC+2'; env differences where local dev build has timezones but production build does not.","solutions":["Enable the timezones feature: polars = { features = [\"timezones\"], ... }.","Use strict fixed-offset format '[-]HH:MM' (e.g. '+02:00', not '+0200' or 'UTC+2') if the feature stays off.","Drop the timezone (cast to naive/UTC timestamp) before JSON serialization.","Align feature flags across dev/CI/production builds to avoid environment-dependent failures."],"exampleFix":"// before\npolars = { version = \"0.46\", features = [\"json\"] }\n// after\npolars = { version = \"0.46\", features = [\"json\", \"timezones\"] }","handlingStrategy":"validation","validationCode":"let timezones_enabled = cfg!(feature = \"polars/timezones\");\nif !timezones_enabled {\n    assert!(tz.len() == 6 && (tz.starts_with('+') || tz.starts_with('-')),\n        \"without 'timezones' feature only [-]HH:MM offsets are accepted, got {tz}\");\n}","typeGuard":"fn is_fixed_offset(tz: &str) -> bool {\n    let b = tz.as_bytes();\n    tz.len() == 6 && (b[0] == b'+' || b[0] == b'-') && tz[1..].chars().all(|c| c.is_ascii_digit() || c == ':')\n}","tryCatchPattern":"// panic arm without the feature; normalize before serializing\nlet safe_tz = if cfg!(feature = \"polars/timezones\") { tz } else { to_fixed_offset(tz).unwrap_or(\"+00:00\") };","preventionTips":["Enable the 'timezones' feature in any build that writes timestamp columns with IANA zones","Without the feature, restrict columns to strict [-]HH:MM offsets","Cast to naive/UTC timestamps before JSON export in minimal builds","Keep feature parity between environments to avoid env-dependent panics"],"tags":["timezone","json","feature-flag","serialization"],"backgroundTag":"feature-not-enabled","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"}