{"record":{"id":"59247b047fcda8b5","repo":"Kuberwastaken/claurst","slug":"bridge-register-auth-error","errorCode":null,"errorMessage":"Bridge register: auth error ({})","messagePattern":"Bridge register: auth error \\((.+?)\\)","errorType":"http","errorClass":"anyhow::Error","httpStatus":401,"severity":"error","filePath":"src-rust/crates/bridge/src/lib.rs","lineNumber":483,"sourceCode":"            .post(&url)\r\n            .bearer_auth(token)\r\n            .header(\"anthropic-version\", \"2023-06-01\")\r\n            .header(\"x-environment-runner-version\", &self.config.runner_version)\r\n            .json(&body)\r\n            .send()\r\n            .await\r\n            .context(\"Bridge register: HTTP send failed\")?;\r\n\r\n        let status = resp.status().as_u16();\r\n        match status {\r\n            200 | 201 => {\r\n                self.set_state(BridgeState::Connected);\r\n                info!(session_id = %self.session_id, \"Bridge session registered\");\r\n                Ok(())\r\n            }\r\n            401 | 403 => {\r\n                self.set_state(BridgeState::Error(format!(\"Auth error: {status}\")));\r\n                anyhow::bail!(\"Bridge register: auth error ({})\", status)\r\n            }\r\n            _ => {\r\n                anyhow::bail!(\"Bridge register: server returned {}\", status)\r\n            }\r\n        }\r\n    }\r\n\r\n    /// Deregister the session on clean shutdown.\r\n    ///\r\n    /// DELETE `/api/claude_code/sessions/{id}` — best-effort; errors are\r\n    /// logged and swallowed so they don't block process exit.\r\n    pub async fn deregister(&self) {\r\n        let Some(token) = self.config.session_token.as_deref() else {\r\n            return;\r\n        };\r\n\r\n        let url = format!(\r\n            \"{}/api/claude_code/sessions/{}\",\r","sourceCodeStart":465,"sourceCodeEnd":501,"githubUrl":"https://github.com/Kuberwastaken/claurst/blob/b0637c97ec34144387cbf2f74f65df6d16a6cef1/src-rust/crates/bridge/src/lib.rs#L465-L501","documentation":"After `exchange_code` succeeds in `run_mcp_auth_session`, the obtained token is persisted via `store_mcp_token`. If the storage write fails, the error is wrapped as \"Failed to store MCP token for '<server>': <e>\". It means the OAuth exchange worked but the credentials could not be saved locally, so subsequent sessions would have to re-authenticate.","triggerScenarios":"`store_mcp_token(&token)` returns Err — the token store file cannot be opened or written (permissions, disk full, corrupted store), or serialization of `McpToken` fails.","commonSituations":"Read-only or noexec home/credential directory (CI containers); disk quota exceeded; credential-store file owned by another user or corrupted by a partial previous write.","solutions":["Read the wrapped inner error to see whether it is a file permission, disk-space, or serialization problem.","Check that the credential/token store location (typically under the user config dir) exists and is writable: `ls -la` and fix ownership/permissions.","Free disk space or fix the quota if the write failed due to capacity.","If the store file is corrupted, move it aside (back it up) and re-run `run_mcp_auth_flow` to recreate it."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if let Err(e) = run_mcp_auth_flow(&session).await {\n    if e.to_string().contains(\"Failed to store MCP token\") {\n        eprintln!(\"Token store unwritable: {} — check permissions/disk space\", e);\n    }\n    return Err(e);\n}","preventionTips":["Ensure the user config/credentials directory exists and is writable before starting auth","Monitor disk space/quota on machines that run the auth flow","Back up and restore a clean token store if it becomes corrupted"],"tags":["oauth","token-storage","file-write","credentials"],"backgroundTag":"file-write-failed","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"}