clockworklabs/SpacetimeDB · error · anyhow::Error

Unknown error

Error message

Unknown error

What it means

During `spacetime login`, the CLI polls the auth server's session endpoint and expects {success, data{approved, sessionToken}}. If the server replies success=false without an error string, the CLI has no reason to surface and falls back to the literal 'Unknown error' placeholder (login.rs:185).

Source

Thrown at crates/cli/src/subcommands/login.rs:185

}

#[derive(Clone, Deserialize)]
struct WebLoginSessionData {
    approved: bool,

    #[serde(rename = "sessionToken")]
    session_token: Option<String>,
}

#[derive(Clone, Deserialize)]
struct WebLoginSessionResponseApproved {
    session_token: String,
}

impl WebLoginSessionResponse {
    fn approved(self) -> anyhow::Result<Option<WebLoginSessionResponseApproved>> {
        if !self.success {
            return Err(anyhow::anyhow!(self
                .error
                .clone()
                .unwrap_or("Unknown error".to_string())));
        }

        let data = self.data.ok_or(anyhow::anyhow!("Response data is missing."))?;
        if !data.approved {
            // Approved is false, no session token expected
            return Ok(None);
        }

        let session_token = data
            .session_token
            .ok_or(anyhow::anyhow!("Session token is missing in response.".to_string()))?;
        Ok(Some(WebLoginSessionResponseApproved {
            session_token: session_token.clone(),
        }))
    }

View on GitHub (pinned to 524b4487d9)

Solutions

  1. Retry `spacetime login` once — transient server-side rejections are common
  2. Verify the server is healthy and that --server points to the intended host
  3. Update the spacetimedb CLI (`spacetime update`) so CLI and server versions match
  4. If self-hosting, check the auth endpoints respond with the documented JSON shape
Defensive patterns

Strategy: retry

Try / catch

for i in 1 2 3; do
  spacetime login && break
  echo "login attempt $i failed; retrying" >&2; sleep $((i * 2))
done

Prevention

When it happens

Trigger: `spacetime login` where the session-polling endpoint returns a body like {"success": false} with the error field omitted or null.

Common situations: Auth server outage or bug; a proxy/gateway rewriting or truncating responses; CLI/server version mismatch; self-hosted node whose auth component is misconfigured.

Related errors


AI-assisted analysis of clockworklabs/SpacetimeDB@524b4487d9 (2026-08-16). Data as JSON: /api/errors/73dd2b79d978a205. Report an issue: GitHub.