{"record":{"id":"8d6bf646f4666f00","repo":"nautechsystems/nautilus_trader","slug":"bundled-australia-sydney-timezone","errorCode":null,"errorMessage":"bundled Australia/Sydney timezone","messagePattern":"bundled Australia/Sydney timezone","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/trading/src/sessions.rs","lineNumber":38,"sourceCode":"//! All FX sessions run Monday to Friday local time:\n//!\n//! - Sydney Session    0700-1600 (Australia / Sydney)\n//! - Tokyo Session     0900-1800 (Asia / Tokyo)\n//! - London Session    0800-1600 (Europe / London)\n//! - New York Session  0800-1700 (America / New York)\n\nuse std::sync::LazyLock;\n\nuse jiff::{\n    Span, Timestamp, Zoned,\n    civil::{Time, Weekday},\n    tz::TimeZone,\n};\nuse nautilus_core::datetime::get_timezone;\nuse strum::{Display, EnumIter, EnumString, FromRepr};\n\nstatic SYDNEY_TIMEZONE: LazyLock<TimeZone> =\n    LazyLock::new(|| get_timezone(\"Australia/Sydney\").expect(\"bundled Australia/Sydney timezone\"));\nstatic TOKYO_TIMEZONE: LazyLock<TimeZone> =\n    LazyLock::new(|| get_timezone(\"Asia/Tokyo\").expect(\"bundled Asia/Tokyo timezone\"));\nstatic LONDON_TIMEZONE: LazyLock<TimeZone> =\n    LazyLock::new(|| get_timezone(\"Europe/London\").expect(\"bundled Europe/London timezone\"));\nstatic NEW_YORK_TIMEZONE: LazyLock<TimeZone> =\n    LazyLock::new(|| get_timezone(\"America/New_York\").expect(\"bundled America/New_York timezone\"));\n\n/// Represents a major Forex market session based on trading hours.\n#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, FromRepr, EnumIter, EnumString, Display)]\n#[strum(ascii_case_insensitive)]\n#[strum(serialize_all = \"SCREAMING_SNAKE_CASE\")]\n#[cfg_attr(\n    feature = \"python\",\n    pyo3::pyclass(\n        eq,\n        eq_int,\n        module = \"nautilus_trader.trading\",\n        from_py_object,","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/trading/src/sessions.rs#L20-L56","documentation":"The Sydney FX session lazily loads the `Australia/Sydney` IANA timezone and panics if it cannot be resolved. The library expects the tz database to be bundled/compiled in (nautilus_core::datetime::get_timezone), so failure means the build or environment lost the bundled timezone data. This is an internal invariant: the identifier is a compile-time constant, so it should always resolve.","triggerScenarios":"First use of the Sydney session constants (e.g. `ForexSession::Sydney` boundary helpers) triggering the `LazyLock`, when `get_timezone(\"Australia/Sydney\")` returns `Err` — typically because the tz database is missing from the binary or the runtime lookup failed.","commonSituations":"Running on a stripped container/minimal OS without tzdata when the crate is configured to load from the system database instead of a bundled one; a dependency change that altered `get_timezone` behavior; cross-compiled builds where the bundled chrono-tz data was dropped by a feature flag.","solutions":["Verify the tz-database feature of the datetime dependency is enabled so IANA names resolve from bundled data.","Install/repair the system tzdata package (tzdata / tzdata пакеты) if the lookup falls back to the OS database.","Confirm the timezone string is exactly `Australia/Sydney` (it is a static constant, so this mainly guards against local edits).","Rebuild the crate after dependency changes so the bundled timezone tables are regenerated."],"exampleFix":"// before (Cargo.toml — bundled tz data disabled)\nchrono = { version = \"0.4\", default-features = false }\n\n// after\nchrono = { version = \"0.4\", features = [\"clock\"] }\nchrono-tz = \"0.9\"  # ensures IANA names like Australia/Sydney resolve at runtime","handlingStrategy":"fallback","validationCode":"// Check the environment before using FX session helpers\nfn tzdata_available() -> bool {\n    std::path::Path::new(\"/usr/share/zoneinfo/Australia/Sydney\").exists()\n}","typeGuard":null,"tryCatchPattern":"// Rust: expect panics — cannot catch; pre-flight the environment instead\nif !tzdata_available() {\n    eprintln!(\"tzdata missing: FX session helpers will panic\");\n    std::process::exit(1);\n}","preventionTips":["Use Docker base images that include tzdata (debian-slim, alpine + `apk add tzdata`).","Prefer builds with the bundled timezone database so no runtime tzdata is needed.","Add a startup smoke test that resolves all four session timezones before entering the trading loop."],"tags":["rust","panic","timezone","initialization"],"backgroundTag":"missing-env-var","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}