Kuberwastaken/claurst · error

Upload: no token

Error message

Upload: no token

What it means

`upload_events` posts pending bridge events to the server and requires the session token for authentication. If `config.session_token` is `None`, the upload fails with this error. This surfaces in the poll loop (`run_poll_loop`) when event uploads run without credentials.

Solutions

  1. Provide `session_token` in the BridgeConfig before entering `run_poll_loop`.
  2. Use the standard start path (`start_bridge_with_client` / token resolution at lib.rs:938) which validates the token up front.
  3. Buffer events locally and retry the upload after the token is restored, instead of dropping them.

Example fix

// before
let config = BridgeConfig { server_url, session_token: None, .. };
bridge.upload_events(&events).await?; // Upload: no token
// after
let config = BridgeConfig {
    server_url,
    session_token: Some(token), // from CLAURST_BRIDGE_TOKEN
    ..Default::default()
};
Defensive patterns

Strategy: validation

Validate before calling

// Ensure credentials exist before entering run_poll_loop
if bridge.config.session_token.is_none() {
    anyhow::bail!("run_poll_loop requires a session token");
}

Try / catch

if let Err(e) = bridge.upload_events(&events).await {
    if e.to_string().contains("no token") {
        // buffer events and re-authenticate before retrying
        pending_events.extend(events);
    }
}

Prevention

When it happens

Trigger: `upload_events` called from `run_poll_loop` while `self.config.session_token` is `None` — bridge configured without a token or token cleared post-registration.

Common situations: Same root cause as 'Poll: no token': a BridgeConfig lacking session_token reaching the event-upload stage; unit tests driving the loop with a minimal config.

Related errors


AI-assisted analysis of Kuberwastaken/claurst@b0637c97ec (2026-09-10). Data as JSON: /api/errors/a514df14015bfd58. Report an issue: GitHub.

Appendix: source

Thrown at src-rust/crates/bridge/src/lib.rs:604

    }

    // -----------------------------------------------------------------------
    // 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
            .session_token
            .as_deref()
            .ok_or_else(|| anyhow::anyhow!("Upload: no token"))?;

        let url = format!(
            "{}/api/claude_code/sessions/{}/events",
            self.config.server_url, self.session_id
        );

        let body = serde_json::json!({ "events": events });

        let resp = self
            .http
            .post(&url)
            .bearer_auth(token)
            .json(&body)
            .send()
            .await
            .context("Bridge upload: HTTP send failed")?;

        if !resp.status().is_success() {

View on GitHub (pinned to b0637c97ec)