{"record":{"id":"0455c50f55a97115","repo":"gitbutlerapp/gitbutler","slug":"fetch-timestamp-does-not-fit-in-the-database-err","errorCode":null,"errorMessage":"fetch timestamp does not fit in the database: {err}","messagePattern":"fetch timestamp does not fit in the database: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-api/src/workspace.rs","lineNumber":130,"sourceCode":"                    .iter()\n                    .map(|(remote, err)| format!(\"{remote}: {err}\"))\n                    .collect::<Vec<_>>()\n                    .join(\"\\n\");\n                let err = anyhow::anyhow!(joined);\n                Err(match code {\n                    Some(code) => err.context(code),\n                    None => err,\n                })\n            }\n        }\n    })();\n\n    let attempted_ms = SystemTime::now()\n        .duration_since(UNIX_EPOCH)\n        .map_err(|err| anyhow::anyhow!(\"system clock is before the Unix epoch: {err}\"))?\n        .as_millis()\n        .try_into()\n        .map_err(|err| anyhow::anyhow!(\"fetch timestamp does not fit in the database: {err}\"))?;\n    let _guard = ctx.exclusive_worktree_access();\n    match &fetch_result {\n        Ok(()) => ctx\n            .db\n            .get_cache_mut()?\n            .fetch_status_mut()\n            .record_success(attempted_ms)?,\n        Err(err) => ctx\n            .db\n            .get_cache_mut()?\n            .fetch_status_mut()\n            .record_failure(attempted_ms, &format!(\"{err:#}\"))?,\n    }\n\n    // A partial failure may still have updated some remote refs.\n    ctx.invalidate_workspace_cache()?;\n    prune_missing_branch_stack_order(ctx)?;\n    fetch_result","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/2497b8007aa4a1922dae9a805b32ffe5b5037785/crates/but-api/src/workspace.rs#L112-L148","documentation":"The fetch timestamp is computed as u128 milliseconds and then narrowed into the i64 stored in the database; a clock beyond roughly year 292 million overflows the narrowing and this guard fires. In practice only a badly corrupted or manipulated clock can trigger it. The check exists so an absurd timestamp fails loudly instead of silently corrupting fetch_status records.","triggerScenarios":"A workspace fetch on a host whose clock is set astronomically far into the future — corrupted RTC, hypervisor clock bug, or clock mocking past i64::MAX milliseconds — so u128 millis no longer fits i64.","commonSituations":"Essentially never in normal use; occasionally seen on flaky embedded boards, after CMOS corruption, or in test rigs that monkeypatch the clock far out of range.","solutions":["Correct the system date and verify with `date -u`.","If it reproduces on one host only, treat it as hardware/hypervisor clock failure rather than a software bug."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const ms = Date.now();\nif (!Number.isSafeInteger(ms) || ms < 0) {\n  throw new Error('system clock reports an implausible time');\n}","typeGuard":null,"tryCatchPattern":"catch (e) {\n  if (String(e.message).includes('fetch timestamp does not fit in the database')) {\n    showFatalError('Host clock invalid', 'The system date is set far in the future; correct it and retry.');\n  }\n}","preventionTips":["Keep hosts NTP-synced.","Clamp or sanity-check client timestamps before triggering syncs.","Do not mock clocks past safe-integer ranges in tests."],"tags":["time","overflow","environment","database","fetch"],"backgroundTag":"timestamp-overflow","analyzedSha":"2497b8007aa4a1922dae9a805b32ffe5b5037785","analyzedAt":"2026-08-17T00:30:25.648Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}