{"record":{"id":"e41fcdcce6683bbc","repo":"nautechsystems/nautilus_trader","slug":"system-clock-before-unix-epoch-e","errorCode":null,"errorMessage":"system clock before Unix epoch: {e}","messagePattern":"system clock before Unix epoch: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/polymarket/src/config.rs","lineNumber":106,"sourceCode":"});\n\nimpl Default for PolymarketUpDownEventSlugConfig {\n    fn default() -> Self {\n        Self::builder().build()\n    }\n}\n\nimpl PolymarketUpDownEventSlugConfig {\n    /// Builds event slugs using the current system time.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if the interval or period count is zero, all assets are\n    /// blank, or the configured offset resolves before the Unix epoch.\n    pub fn build_event_slugs(&self) -> anyhow::Result<Vec<String>> {\n        let now = SystemTime::now()\n            .duration_since(UNIX_EPOCH)\n            .map_err(|e| anyhow::anyhow!(\"system clock before Unix epoch: {e}\"))?\n            .as_secs();\n        self.build_event_slugs_at_unix_secs(now)\n    }\n\n    fn build_event_slugs_at_unix_secs(&self, unix_secs: u64) -> anyhow::Result<Vec<String>> {\n        if self.interval_mins == 0 {\n            anyhow::bail!(\"event_slug_builder.interval_mins must be positive\");\n        }\n\n        if self.periods == 0 {\n            anyhow::bail!(\"event_slug_builder.periods must be positive\");\n        }\n\n        let assets = self.normalized_assets();\n        if assets.is_empty() {\n            anyhow::bail!(\"event_slug_builder.assets must include at least one non-empty asset\");\n        }\n","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/polymarket/src/config.rs#L88-L124","documentation":"build_event_slugs takes the current time via SystemTime::now().duration_since(UNIX_EPOCH) to compute the current up/down market period. This error is thrown when the system clock reports a time before the Unix epoch (a negative duration), which cannot be represented as u64 seconds, so slug construction must fail rather than compute a bogus period.","triggerScenarios":"Calling PolymarketConfig::build_event_slugs while the host clock is set earlier than 1970-01-01T00:00:00Z — e.g. a VM/container without RTC that hasn't synced NTP, or a clock reset.","commonSituations":"Fresh VMs or embedded devices booting with default BIOS/CMOS dates; containers started before NTP sync; clock drift or deliberate time skew in CI sandboxes.","solutions":["Sync the system clock (systemctl restart systemd-timesyncd / ntpdate / wait for chronyd) and retry.","Check `date -u` on the host; if the year is before 1970, fix the RTC/timezone configuration.","In containers, ensure the host clock is correct and time namespacing isn't skewing the container view.","If your environment deliberately fakes time, call the deterministic sibling build_event_slugs_at_unix_secs with an explicit timestamp instead."],"exampleFix":"// before: host clock at 1969\nlet slugs = config.build_event_slugs()?;\n// after: fix host time, or inject time deterministically\nsudo chronyc makestep\nlet slugs = config.build_event_slugs_at_unix_secs(explicit_unix_secs)?;","handlingStrategy":"validation","validationCode":"// Rust: verify the host clock is sane before building slugs\nfn clock_is_sane() -> bool {\n    std::time::SystemTime::now()\n        .duration_since(std::time::UNIX_EPOCH)\n        .map(|d| d.as_secs() > 1_600_000_000) // after Sep 2020\n        .unwrap_or(false)\n}","typeGuard":null,"tryCatchPattern":"match config.build_event_slugs() {\n    Ok(slugs) => use(slugs),\n    Err(e) if e.to_string().contains(\"Unix epoch\") => {\n        sync_system_clock(); // ntpdate / chronyc makestep\n        retry(config.build_event_slugs())\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Enable NTP/chrony on hosts running the adapter, especially VMs and containers.","Check `date -u` in startup/health checks before initializing time-derived config.","Use build_event_slugs_at_unix_secs with an injected timestamp in tests or controlled-time environments."],"tags":["clock","environment","polymarket","config"],"backgroundTag":"invalid-config-value","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"}