{"record":{"id":"8d6939ea4ff507ad","repo":"jdx/mise","slug":"invalid-github-relay-timeout-policy","errorCode":null,"errorMessage":"invalid GitHub relay timeout policy","messagePattern":"invalid GitHub relay timeout policy","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/github_relay.rs","lineNumber":1036,"sourceCode":"        let response = builder()\n            .build()?\n            .get(\"http://localhost/_session\")\n            .timeout(Duration::from_secs(3))\n            .send()\n            .await\n            .map_err(|error| {\n                eyre::Report::new(error.without_url()).wrap_err(\"GitHub relay policy unavailable\")\n            })?;\n        if response.status() != 204 {\n            bail!(\"GitHub relay is not connected\");\n        }\n        let value = response\n            .headers()\n            .get(\"x-mise-relay-timeout\")\n            .ok_or_else(|| eyre::eyre!(\"GitHub relay timeout policy missing\"))?;\n        let timeout: Duration = serde_json::from_slice(value.as_bytes())?;\n        if timeout.is_zero() || std::time::Instant::now().checked_add(timeout).is_none() {\n            bail!(\"invalid GitHub relay timeout policy\");\n        }\n        Ok((builder().read_timeout(timeout).build()?, timeout))\n    }\n\n    // Bound connecting and writing as well as waiting for response headers.\n    // The client's read timeout separately protects the streamed response.\n    async fn send_adapter_request(\n        req: reqwest::RequestBuilder,\n        timeout: Duration,\n    ) -> Result<reqwest::Response> {\n        tokio::time::timeout(timeout, req.send())\n            .await\n            .map_err(|_| eyre::eyre!(\"GitHub relay request setup timed out\"))?\n            .map_err(|error| {\n                eyre::Report::new(error.without_url())\n                    .wrap_err(\"GitHub relay disconnected or unavailable\")\n            })\n    }","sourceCodeStart":1018,"sourceCodeEnd":1054,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/github_relay.rs#L1018-L1054","documentation":"`adapter_client` reads the relay timeout policy from the `x-mise-relay-timeout` response header and deserializes it into a Duration. If the value is zero or too large to add to the current instant (i.e. overflowing `Instant`), the policy is considered invalid and the error is raised. It protects callers from a nonsensical or unusable timeout.","triggerScenarios":"The relay advertises `x-mise-relay-timeout` as 0; the header contains a Duration value that fails serde parsing (wrong format/type) — surfacing a parse error instead; the header contains a huge duration that overflows Instant::checked_add.","commonSituations":"Version mismatch between relay server and client where the header format changed; a misbehaving or mocked relay emitting an invalid header; tests/stubs that set the header to `0` to disable timeouts.","solutions":["Update both the relay and mise so the x-mise-relay-timeout header format matches between versions.","Check what the relay is sending (inspect the header with a proxy or relay logs) and correct the emitting side.","If you control a stub/mock relay, emit a positive, sane Duration value in the expected serde format.","As a workaround, run without the relay (direct GitHub access) if your environment permits."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"let (client, timeout) = match adapter_client(&socket).await {\n    Err(e) if e.to_string().contains(\"invalid GitHub relay timeout policy\") => {\n        eprintln!(\"relay timeout header invalid; using default timeout\");\n        fallback_client_with_default_timeout(&socket).await?\n    }\n    other => other?,\n};","preventionTips":["Run matching relay and mise versions so the x-mise-relay-timeout format agrees","Never stub the header with 0 or malformed durations in test relays","Validate advertised timeout headers when operating a custom relay"],"tags":["http","header","timeout","relay","config"],"backgroundTag":"invalid-config-value","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"}