Kuberwastaken/claurst · error · anyhow::Error
Bridge poll: server returned
Error message
Bridge poll: server returned {} What it means
`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.
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.
Defensive patterns
Strategy: validation
Validate before calling
// before refreshing, check the token exists
if get_mcp_token(server_name).is_none() {
run_mcp_auth_flow(&session).await?; // authenticate first
} Try / catch
match refresh_mcp_token(server, endpoint).await {
Ok(t) => t,
Err(e) if e.to_string().starts_with("No stored token") => {
run_mcp_auth_flow(&session).await? // fall back to full auth
}
Err(e) => return Err(e),
} Prevention
- 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
When it happens
Trigger: `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`.
Common situations: 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.
Understand the failure class
Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.
Related errors
- Bridge upload: server returned
- start_bridge: bridge is not active
- models endpoint returned
- Invalid JWT: expected at least 2 dot-separated segments
- Invalid : contains unsafe characters
AI-assisted analysis of Kuberwastaken/claurst@b0637c97ec (2026-09-10).
Data as JSON: /api/errors/c39af83c73895768.
Report an issue: GitHub.
Appendix: source
Thrown at src-rust/crates/bridge/src/lib.rs:583
let status = resp.status().as_u16();
match status {
200 => {
let text = resp.text().await.context("Bridge poll: reading body")?;
if text.trim().is_empty() || text.trim() == "[]" {
return Ok(vec![]);
}
let msgs: Vec<BridgeMessage> =
serde_json::from_str(&text).context("Bridge poll: JSON parse")?;
Ok(msgs)
}
204 => Ok(vec![]),
401 | 403 => {
self.set_state(BridgeState::Error(format!("Auth error: {status}")));
anyhow::bail!("Bridge poll: auth error ({})", status)
}
_ => {
anyhow::bail!("Bridge poll: server returned {}", status)
}
}
}
// -----------------------------------------------------------------------
// Event upload
// -----------------------------------------------------------------------
/// Batch-upload outgoing events to the web UI.
///
/// POST `/api/claude_code/sessions/{id}/events`
async fn upload_events(&self, events: Vec<BridgeEvent>) -> anyhow::Result<()> {
if events.is_empty() {
return Ok(());
}
let token = self
.config
View on GitHub (pinned to b0637c97ec)