{"record":{"id":"cc6e7516f3ca632a","repo":"pola-rs/polars","slug":"timezone-cannot-be-parsed-feature-chrono-tz-is-not-active","errorCode":null,"errorMessage":"timezone \"{}\" cannot be parsed (feature chrono-tz is not active)","messagePattern":"timezone \"(.+?)\" cannot be parsed \\(feature chrono-tz is not active\\)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/polars-arrow/src/compute/temporal.rs","lineNumber":282,"sourceCode":"    O: NativeType,\n    F: Fn(chrono::DateTime<chrono_tz::Tz>) -> O,\n{\n    let timezone = parse_offset_tz(timezone_str)?;\n    Ok(extract_impl(array, time_unit, timezone, op))\n}\n\n#[cfg(not(feature = \"chrono-tz\"))]\nfn chrono_tz<F, O>(\n    _: &PrimitiveArray<i64>,\n    _: TimeUnit,\n    timezone_str: &str,\n    _: F,\n) -> PolarsResult<PrimitiveArray<O>>\nwhere\n    O: NativeType,\n    F: Fn(chrono::DateTime<chrono::FixedOffset>) -> O,\n{\n    panic!(\n        \"timezone \\\"{}\\\" cannot be parsed (feature chrono-tz is not active)\",\n        timezone_str\n    )\n}\n\nfn extract_impl<T, A, F>(\n    array: &PrimitiveArray<i64>,\n    time_unit: TimeUnit,\n    timezone: T,\n    extract: F,\n) -> PrimitiveArray<A>\nwhere\n    T: chrono::TimeZone,\n    A: NativeType,\n    F: Fn(chrono::DateTime<T>) -> A,\n{\n    let timestamp_to_datetime_opt: fn(i64) -> Option<chrono::NaiveDateTime> = match time_unit {\n        TimeUnit::Second => timestamp_s_to_datetime_opt,","sourceCodeStart":264,"sourceCodeEnd":300,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/crates/polars-arrow/src/compute/temporal.rs#L264-L300","documentation":"This panic comes from the fallback implementation of temporal timezone conversion in polars-arrow that is compiled when the optional `chrono-tz` feature is NOT enabled. The function is the stub used in place of the real converter: any attempt to interpret a timestamp in a named timezone (e.g. \"America/New_York\") hits this panic because the IANA timezone database is only available with the feature active. It is a hard panic, not a Result error, so it aborts the compute operation.","triggerScenarios":"Calling temporal compute functions like extract_impl/chronotype conversion (e.g. Datetime `.dt.year()`-style operations in polars-arrow) on a PrimitiveArray whose Datetime logical type carries a named timezone string while the `chrono-tz` cargo feature is disabled.","commonSituations":"Using polars-arrow (or polars built without default features) with `default-features = false` and forgetting to add the `chrono-tz` feature; running timestamp-with-timezone operations in a slimmed-down dependency tree; Cargo workspace feature unification unexpectedly dropping the feature.","solutions":["Enable the feature in Cargo.toml: polars-arrow = { version = \"...\", features = [\"chrono-tz\"] } (or polars with `features = [\"temporal\", \"chrono-tz\"]`).","If features are not an option, use a fixed-offset timezone (e.g. \"+02:00\") instead of a named IANA zone, since FixedOffset parsing does not require chrono-tz.","Check `cargo tree -e features -p polars-arrow` to confirm `chrono-tz` is actually activated; another dependency may disable default features and prune it.","Wrap .dt timezone operations behind a runtime check that the build supports chrono-tz before exposing the functionality."],"exampleFix":"// before (Cargo.toml)\npolars = { version = \"0.x\", default-features = false, features = [\"lazy\"] }\n// after\npolars = { version = \"0.x\", default-features = false, features = [\"lazy\", \"temporal\", \"chrono-tz\"] }","handlingStrategy":"validation","validationCode":"// Cargo.toml check before using tz-aware dt ops\nfn assert_chrono_tz_available() {\n    #[cfg(not(feature = \"chrono-tz\"))]\n    compile_error!(\"chrono-tz feature required for named-timezone operations\");\n}\n// or at runtime: avoid named tz strings unless feature is on","typeGuard":"fn uses_named_timezone(tz: &str) -> bool {\n    !(tz.starts_with('+') || tz.starts_with('-') || tz.eq_ignore_ascii_case(\"UTC\"))\n}","tryCatchPattern":"// panic, not Result — isolate with catch_unwind if needed\nlet result = std::panic::catch_unwind(|| extract_with_tz(&arr, tz));","preventionTips":["Always enable chrono-tz when handling tz-aware timestamps","Audit feature flags when using default-features = false","Prefer fixed-offset timezones in minimal builds","Check cargo tree for pruned features in workspaces"],"tags":["rust","feature-flag","timezone","chrono-tz","panic"],"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"}