{"record":{"id":"c880d5361ecc49d1","repo":"Hmbown/CodeWhale","slug":"mcp-oauth-setup-cancelled-after-plugin-authority-c","errorCode":null,"errorMessage":"MCP OAuth setup cancelled after plugin authority changed","messagePattern":"MCP OAuth setup cancelled after plugin authority changed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/tui/src/mcp.rs","lineNumber":1722,"sourceCode":"            }\n            let client = http_client::McpHttpClient::new(\n                url,\n                config.runtime_added,\n                config.reviewed_plugin.is_some(),\n                config.allow_private_network,\n                network_policy,\n                Duration::from_secs(connect_timeout_secs),\n                Duration::from_secs(read_timeout_secs),\n            )?;\n            let oauth_runtime = if config.reviewed_plugin.is_some() {\n                None\n            } else {\n                match oauth::build_default_headers(&config.headers, &config.env_headers) {\n                    Ok(default_headers) => {\n                        let prepared = tokio::select! {\n                            biased;\n                            _ = cancel_token.cancelled() => {\n                                anyhow::bail!(\n                                    \"MCP OAuth setup cancelled after plugin authority changed\"\n                                )\n                            }\n                            prepared = oauth::McpOAuthRuntime::from_server_config_with_client(\n                                &name,\n                                &config,\n                                default_headers,\n                                client.clone(),\n                            ) => prepared,\n                        };\n                        match prepared {\n                            Ok(runtime) => runtime,\n                            Err(err) => {\n                                if config.reviewed_plugin.is_some() {\n                                    tracing::warn!(\n                                        target: \"mcp\",\n                                        server = %name,\n                                        \"failed to prepare reviewed plugin MCP OAuth runtime; provider details suppressed; continuing without stored OAuth token\"","sourceCodeStart":1704,"sourceCodeEnd":1740,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/mcp.rs#L1704-L1740","documentation":"During MCP server setup that involves OAuth, the runtime is built inside tokio::select! with the session cancel token racing the OAuth client construction. If cancellation wins (because the plugin authority — the reviewed-plugin generation governing the server's permissions — changed), the setup is aborted with this bail. The operation was made stale by a concurrent policy/authority change, so it must not proceed.","triggerScenarios":"An MCP OAuth setup flow is in flight when the reviewed plugin authority changes (plugin re-review, revocation, or generation bump), firing cancel_token.cancelled() before the OAuth runtime finishes constructing.","commonSituations":"A plugin's permissions are revoked or re-approved by a concurrent process while the user is mid-OAuth; editing/reviewing plugin settings during a connecting MCP server's OAuth handshake.","solutions":["Retry the MCP server connection after the plugin authority change settles","Re-review/re-approve the plugin so its generation is current, then reconnect","Avoid changing plugin permissions while an MCP OAuth handshake is in flight","Restart the session if the cancel token remains latched"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"match connect(name).await {\n    Err(e) if e.to_string().contains(\"plugin authority changed\") => {\n        // wait for the authority to settle, then retry once\n        tokio::time::sleep(Duration::from_secs(1)).await;\n        connect(name).await\n    }\n    other => other,\n}","preventionTips":["Don't edit plugin permissions while MCP connections are initializing","Serialize plugin reviews and server setup","Reconnect after any plugin generation bump"],"tags":["mcp","oauth","cancelled"],"backgroundTag":"operation-cancelled","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}