{"record":{"id":"0f7d0fe57f172c2b","repo":"zed-industries/zed","slug":"token-is-not-yet-valid","errorCode":null,"errorMessage":"token is not yet valid","messagePattern":"token is not yet valid","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/livekit_api/src/token.rs","lineNumber":173,"sourceCode":"\n#[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)","sourceCodeStart":155,"sourceCodeEnd":191,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/livekit_api/src/token.rs#L155-L191","documentation":"Claim check in validate_with_timestamp_source: the token's nbf (not-before) claim is later than the timestamp source's current time, so the token is structurally valid but not yet active. This is a test-support validator comparing claims against an injected clock.","triggerScenarios":"Thrown at crates/livekit_api/src/token.rs:173 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Wait until the token's not-before time passes, or request a token valid now","Correct the clock/timestamp source used when issuing or validating the token"],"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-14T05:17:10.506Z"}