{"record":{"id":"48fc5d24d1e7914b","repo":"jdx/mise","slug":"github-actions-oidc-token-expires-too-soon","errorCode":null,"errorMessage":"GitHub Actions OIDC token expires too soon","messagePattern":"GitHub Actions OIDC token expires too soon","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/mise-cache-core/src/lib.rs","lineNumber":1060,"sourceCode":"                    .client\n                    .get(self.request_url.clone())\n                    .header(AUTHORIZATION, self.request_token.clone())\n                    .send()\n                    .await?\n                    .error_for_status()?\n                    .json()\n                    .await?)\n            })\n            .await\n            .map_err(|err| {\n                eyre!(\n                    \"failed to acquire GitHub Actions OIDC token for audience {:?}: {err}\",\n                    self.audience\n                )\n            })?;\n        let expires_at = jwt_expiry(&response.value)?;\n        if expires_at <= now.saturating_add(REFRESH_LEEWAY_SECONDS) {\n            bail!(\"GitHub Actions OIDC token expires too soon\");\n        }\n        let authorization = authorization_header(Some(&response.value))?\n            .ok_or_else(|| eyre!(\"GitHub Actions returned an empty OIDC token\"))?;\n        *cached = Some(CachedOidcToken {\n            authorization: authorization.clone(),\n            expires_at,\n        });\n        Ok(authorization)\n    }\n}\n\nfn jwt_expiry(token: &str) -> Result<u64> {\n    let payload = token\n        .split('.')\n        .nth(1)\n        .ok_or_else(|| eyre!(\"GitHub Actions returned a malformed OIDC token\"))?;\n    let payload = URL_SAFE_NO_PAD\n        .decode(payload)","sourceCodeStart":1042,"sourceCodeEnd":1078,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/crates/mise-cache-core/src/lib.rs#L1042-L1078","documentation":"The GitHub Actions OIDC provider returned a token whose JWT expiry is not far enough in the future relative to REFRESH_LEEWAY_SECONDS. The client refuses to cache tokens that would expire almost immediately, because they could not be safely reused. This indicates an issuer/configuration problem rather than a transient failure.","triggerScenarios":"jwt_expiry(&response.value) returns a timestamp <= now + REFRESH_LEEWAY_SECONDS while acquiring a GitHub Actions OIDC token for the configured audience.","commonSituations":"A non-GitHub endpoint mimicking the OIDC provider returning hand-rolled tokens with short/no expiry, clock skew between runner and token issuer, misconfigured ACTIONS_ID_TOKEN_REQUEST_URL pointing at a stub server.","solutions":["Ensure the OIDC request URL points at the genuine GitHub Actions token endpoint ($ACTIONS_ID_TOKEN_REQUEST_URL) rather than a stub","Check runner/system clock skew (NTP sync) so 'now' is not drifted ahead of the token's iat/exp","Decode the returned JWT and inspect its exp claim to see who issued it and when it expires","Request a fresh token rather than relying on an externally supplied one"],"exampleFix":"// before: custom/stub token endpoint with near-expiry tokens\nlet url = \"http://localhost:9999/token\";\n// after: use the GitHub-provided endpoint\nlet url = std::env::var(\"ACTIONS_ID_TOKEN_REQUEST_URL\")?;","handlingStrategy":"validation","validationCode":"// before requesting, confirm we're using the genuine GitHub endpoint\nlet url = std::env::var(\"ACTIONS_ID_TOKEN_REQUEST_URL\")\n    .expect(\"ACTIONS_ID_TOKEN_REQUEST_URL must be set by GitHub Actions\");\nassert!(url.starts_with(\"http\"), \"OIDC URL not configured\");","typeGuard":"fn has_future_expiry(token: &str, leeway_secs: u64, now: u64) -> bool {\n    jwt_expiry(token).map(|exp| exp > now + leeway_secs).unwrap_or(false)\n}","tryCatchPattern":"match provider.token(audience).await {\n    Err(e) if e.to_string().contains(\"expires too soon\") => {\n        // check clock skew / issuer before retrying\n    }\n    other => other,\n}","preventionTips":["Sync runner clocks with NTP","Only point OIDC requests at the GitHub-provided ACTIONS_ID_TOKEN_REQUEST_URL","Log the JWT header/claims (not the signature) when debugging issuers"],"tags":["oidc","github-actions","jwt","authentication"],"backgroundTag":"jwt-token-expired","analyzedSha":"533346cc374382b41ec5ff70536252b2e96e725c","analyzedAt":"2026-09-17T13:35:38.149Z","contentChangedAt":"2026-09-17T13:35:38.149Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}