{"record":{"id":"cf7e010929bf4ff5","repo":"zed-industries/zed","slug":"token-has-expired","errorCode":null,"errorMessage":"token has expired","messagePattern":"token has expired","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/livekit_api/src/token.rs","lineNumber":174,"sourceCode":"#[cfg(any(test, feature = \"test-support\"))]\npub fn validate_with_timestamp_source<'a>(\n    token: &'a str,\n    secret_key: &str,\n    timestamp_source: &dyn UnixTimestampSource,\n) -> Result<ClaimGrants<'a>> {\n    let mut validation = Validation::default();\n    validation.validate_exp = false;\n    validation.validate_nbf = false;\n    let token: jsonwebtoken::TokenData<ClaimGrants<'_>> = jsonwebtoken::decode(\n        token,\n        &DecodingKey::from_secret(secret_key.as_ref()),\n        &validation,\n    )?;\n    let claims = token.claims;\n    let timestamp = timestamp_source.unix_timestamp()?;\n\n    anyhow::ensure!(claims.nbf <= timestamp, \"token is not yet valid\");\n    anyhow::ensure!(claims.exp > timestamp, \"token has expired\");\n\n    Ok(claims)\n}\n\n#[cfg(test)]\nmod tests {\n    use super::*;\n    use crate::{Client as _, LiveKitClient};\n    use std::sync::Arc;\n\n    const ISSUED_AT: u64 = 1_234_567;\n\n    struct FixedUnixTimestampSource(u64);\n\n    impl UnixTimestampSource for FixedUnixTimestampSource {\n        fn unix_timestamp(&self) -> Result<u64> {\n            Ok(self.0)\n        }","sourceCodeStart":156,"sourceCodeEnd":192,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/livekit_api/src/token.rs#L156-L192","documentation":"In LiveKit token validation (validate_with_timestamp_source): the JWT signature decoded successfully but its `exp` claim is earlier than the current timestamp (from the injected timestamp source), meaning the token's validity window has passed and it must not be accepted.","triggerScenarios":"Thrown at crates/livekit_api/src/token.rs:174 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Mint a fresh LiveKit token with a later exp","Extend token TTL on the issuing side if tokens expire during sessions"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}