{"record":{"id":"73dd2b79d978a205","repo":"clockworklabs/SpacetimeDB","slug":"unknown-error","errorCode":null,"errorMessage":"Unknown error","messagePattern":"Unknown error","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/cli/src/subcommands/login.rs","lineNumber":185,"sourceCode":"}\n\n#[derive(Clone, Deserialize)]\nstruct WebLoginSessionData {\n    approved: bool,\n\n    #[serde(rename = \"sessionToken\")]\n    session_token: Option<String>,\n}\n\n#[derive(Clone, Deserialize)]\nstruct WebLoginSessionResponseApproved {\n    session_token: String,\n}\n\nimpl WebLoginSessionResponse {\n    fn approved(self) -> anyhow::Result<Option<WebLoginSessionResponseApproved>> {\n        if !self.success {\n            return Err(anyhow::anyhow!(self\n                .error\n                .clone()\n                .unwrap_or(\"Unknown error\".to_string())));\n        }\n\n        let data = self.data.ok_or(anyhow::anyhow!(\"Response data is missing.\"))?;\n        if !data.approved {\n            // Approved is false, no session token expected\n            return Ok(None);\n        }\n\n        let session_token = data\n            .session_token\n            .ok_or(anyhow::anyhow!(\"Session token is missing in response.\".to_string()))?;\n        Ok(Some(WebLoginSessionResponseApproved {\n            session_token: session_token.clone(),\n        }))\n    }","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/6dee26c6efc2856793e12b148a59742964f5d783/crates/cli/src/subcommands/login.rs#L167-L203","documentation":"During web login, the CLI polls the login-session endpoint and deserializes a WebLoginSessionResponse. If the response has success: false, the error message is taken from the response's optional `error` field; when the server omits it, the CLI falls back to the generic 'Unknown error'. So this error always represents a server-side rejection of the login session whose cause the API did not report.","triggerScenarios":"The login-session API returns HTTP 200 with JSON {success: false} and no `error` field — e.g. the session token expired server-side while you sat on the browser approval page, the request token was already consumed, or an auth backend issue. Distinct from network/HTTP failures, which surface as reqwest errors before this point.","commonSituations":"Waiting too long (tab left open) between `spacetime login` and clicking Approve in the browser, letting the session expire; retrying a login with a stale request token behind a proxy that caches responses; maincloud auth incidents returning bare failure responses.","solutions":["Cancel and restart `spacetime login` to mint a fresh request token and session","Approve the browser prompt promptly after the CLI prints the URL","If it persists, check the server's status page / try `spacetime login --no-browser` and open the URL manually in a clean profile (extensions can break the approval page)"],"exampleFix":"# before: stale/expired session\n(spacetime login prompt left open for a long time)\n# after\nspacetime login   # restart; approve promptly","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"until spacetime login; do echo 'login session rejected — retrying with a fresh token'; sleep 2; done  # bounded in practice: approve promptly","preventionTips":["Approve the browser prompt immediately after the CLI prints the login URL — sessions expire","Restart the whole login flow rather than refreshing the browser tab on a stale token","Use `spacetime login --no-browser` on headless machines and open the URL in a normal browser profile"],"tags":["cli","login","auth","web-login","api-error"],"backgroundTag":"auth-session-rejected","analyzedSha":"6dee26c6efc2856793e12b148a59742964f5d783","analyzedAt":"2026-08-20T06:08:37.179Z","contentChangedAt":"2026-08-20T06:08:37.179Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}