{"record":{"id":"c39af83c73895768","repo":"Kuberwastaken/claurst","slug":"bridge-poll-server-returned","errorCode":null,"errorMessage":"Bridge poll: server returned {}","messagePattern":"Bridge poll: server returned (.+?)","errorType":"http","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src-rust/crates/bridge/src/lib.rs","lineNumber":583,"sourceCode":"\r\n        let status = resp.status().as_u16();\r\n        match status {\r\n            200 => {\r\n                let text = resp.text().await.context(\"Bridge poll: reading body\")?;\r\n                if text.trim().is_empty() || text.trim() == \"[]\" {\r\n                    return Ok(vec![]);\r\n                }\r\n                let msgs: Vec<BridgeMessage> =\r\n                    serde_json::from_str(&text).context(\"Bridge poll: JSON parse\")?;\r\n                Ok(msgs)\r\n            }\r\n            204 => Ok(vec![]),\r\n            401 | 403 => {\r\n                self.set_state(BridgeState::Error(format!(\"Auth error: {status}\")));\r\n                anyhow::bail!(\"Bridge poll: auth error ({})\", status)\r\n            }\r\n            _ => {\r\n                anyhow::bail!(\"Bridge poll: server returned {}\", status)\r\n            }\r\n        }\r\n    }\r\n\r\n    // -----------------------------------------------------------------------\r\n    // Event upload\r\n    // -----------------------------------------------------------------------\r\n\r\n    /// Batch-upload outgoing events to the web UI.\r\n    ///\r\n    /// POST `/api/claude_code/sessions/{id}/events`\r\n    async fn upload_events(&self, events: Vec<BridgeEvent>) -> anyhow::Result<()> {\r\n        if events.is_empty() {\r\n            return Ok(());\r\n        }\r\n\r\n        let token = self\r\n            .config\r","sourceCodeStart":565,"sourceCodeEnd":601,"githubUrl":"https://github.com/Kuberwastaken/claurst/blob/b0637c97ec34144387cbf2f74f65df6d16a6cef1/src-rust/crates/bridge/src/lib.rs#L565-L601","documentation":"`refresh_mcp_token` first loads the previously stored token via `get_mcp_token(server_name)`. If no token has ever been stored under that server name, it returns \"No stored token for <server_name>\". Refreshing requires an existing stored token; this error means the caller asked to refresh credentials that do not exist yet.","triggerScenarios":"`get_mcp_token(server_name)` returns None — the server name passed to `refresh_mcp_token` (via `get_valid_mcp_token`) does not match any entry in the token store, or the token was never obtained through `run_mcp_auth_flow`.","commonSituations":"Typo in the server name (refreshing \"github\" when stored as \"GitHub\"); fresh machine/container where auth was never run; the token store file was deleted or reset; config renamed the MCP server without re-authenticating.","solutions":["Run `run_mcp_auth_flow` for this server to obtain and store an initial token before refreshing.","Verify the server name matches exactly the `server_name` used when the token was stored (case and spelling).","Check the token store file exists and contains an entry for this server.","If the server was renamed in config, either re-auth under the new name or migrate the stored entry."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// before refreshing, check the token exists\nif get_mcp_token(server_name).is_none() {\n    run_mcp_auth_flow(&session).await?; // authenticate first\n}","typeGuard":null,"tryCatchPattern":"match refresh_mcp_token(server, endpoint).await {\n    Ok(t) => t,\n    Err(e) if e.to_string().starts_with(\"No stored token\") => {\n        run_mcp_auth_flow(&session).await? // fall back to full auth\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Always run the initial auth flow before any operation that may refresh tokens","Keep server names consistent (copy them from config, don't retype)","Check the token store contents when debugging name mismatches"],"tags":["oauth","token-store","refresh","lookup"],"backgroundTag":"record-not-found","analyzedSha":"b0637c97ec34144387cbf2f74f65df6d16a6cef1","analyzedAt":"2026-09-10T00:24:58.650Z","contentChangedAt":"2026-09-10T00:24:58.650Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}