{"record":{"id":"52a5702b5dbbb5f6","repo":"astrid-runtime/astrid","slug":"winfsp-lease-is-expired","errorCode":null,"errorMessage":"WinFsp lease is expired","messagePattern":"WinFsp lease is expired","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-storage-provider-winfsp/src/win.rs","lineNumber":263,"sourceCode":"        || launch.parent.token.chars().any(char::is_control)\n    {\n        bail!(\"WinFsp service parent token is invalid\");\n    }\n    if let Some(identity) = launch.parent.start_identity.as_deref()\n        && (identity.is_empty() || identity.len() > 512 || identity.chars().any(char::is_control))\n    {\n        bail!(\"WinFsp service parent start identity is invalid\");\n    }\n    if launch.parent.start_identity.is_none() {\n        bail!(\"WinFsp service parent start identity is required on Windows\");\n    }\n    let lease = &launch.lease;\n    let now = SystemTime::now()\n        .duration_since(UNIX_EPOCH)\n        .context(\"read system clock\")?\n        .as_secs();\n    if lease.expires_at_epoch_secs < now {\n        bail!(\"WinFsp lease is expired\");\n    }\n    if lease.lease_token.len() < 16 || lease.lease_token.len() > 4096 {\n        bail!(\"WinFsp lease callback token is invalid\");\n    }\n    if !lease.resource_path.is_absolute()\n        || !lease.callback_path.is_absolute()\n        || lease.callback_path != lease.resource_path.join(\"control.endpoint\")\n    {\n        bail!(\"WinFsp lease paths are malformed\");\n    }\n    platform_fs::validate_private_directory(&lease.resource_path)\n        .context(\"validate private WinFsp lease resource\")?;\n    platform_fs::verify_no_redirects(&lease.resource_path)\n        .context(\"reject redirected WinFsp lease resource\")?;\n    let manifest_path = lease.resource_path.join(\"lease.json\");\n    platform_fs::validate_private_file(&manifest_path)\n        .context(\"validate private WinFsp lease manifest\")?;\n    let manifest = std::fs::read(&manifest_path).context(\"read WinFsp lease manifest\")?;","sourceCodeStart":245,"sourceCodeEnd":281,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-storage-provider-winfsp/src/win.rs#L245-L281","documentation":"Each mount lease carries an absolute expiry (expires_at_epoch_secs, Unix seconds). validate_service_launch compares it to the current system clock and aborts the mount if the lease has already expired. This enforces that only time-valid leases can bring up a WinFsp filesystem, preventing stale mounts from being resurrected.","triggerScenarios":"service_main -> validate_service_launch where lease.expires_at_epoch_secs < SystemTime::now() duration since UNIX_EPOCH in seconds: the lease file (lease.json) was created earlier and its validity window has passed before/at service start.","commonSituations":"Resuming a session or replaying a saved launch descriptor hours later; a machine with a wrong system clock (skewed forward, or timezone/clock jumps after resume from sleep or VM snapshot) makes a fresh lease look expired; long CI queues where the lease was minted at queue time but consumed late.","solutions":["Obtain a fresh lease (re-run the mount request through the provider) so expires_at_epoch_secs is in the future, instead of replaying an old launch descriptor.","Check the system clock on the service host (w32tm /query /status; re-sync with time.windows.com) — a forward clock skew alone produces this error with a valid lease.","Re-mint the launch file right before starting the service; avoid persisting launch descriptors across restarts or long waits.","If leases expire during legitimate startup delays, increase the lease TTL in the code that issues StorageMountLeaseV1."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"let now = std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH)?.as_secs();\nif lease.expires_at_epoch_secs <= now {\n    return Err(anyhow!(\"lease expired at {} (now {}): re-issue the lease\", lease.expires_at_epoch_secs, now));\n}","typeGuard":null,"tryCatchPattern":"match validate_launch(&launch) {\n    Err(e) if e.to_string().contains(\"lease is expired\") => reissue_lease_and_retry(),\n    Err(e) => return Err(e),\n    Ok(()) => start_service(&launch),\n}","preventionTips":["Always mint a fresh lease immediately before service start; never replay saved launch files","Monitor system clock sync (NTP) on hosts running the service","Set lease TTLs comfortably larger than worst-case startup/queue delays","Treat this error as retryable-after-reissue, not retryable-as-is"],"tags":["winfsp","lease","expiry","time"],"backgroundTag":"jwt-token-expired","analyzedSha":"affd8760f44190dbdfbec23403f4c4b642c33112","analyzedAt":"2026-09-09T21:28:12.402Z","contentChangedAt":"2026-09-09T21:28:12.402Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}