{"record":{"id":"6fc49d4633fe6f61","repo":"zed-industries/zed","slug":"authorization-channel-closed","errorCode":null,"errorMessage":"authorization channel closed","messagePattern":"authorization channel closed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/agent/src/thread.rs","lineNumber":5892,"sourceCode":"                return Err(anyhow!(\"Failed to send sandbox authorization: {error}\"));\n            }\n\n            let (mut settings_tx, mut settings_rx) = watch::channel(());\n            let _settings_subscription = cx.update(|cx| {\n                cx.observe_global::<SettingsStore>(move |_cx| {\n                    settings_tx.send(()).ok();\n                })\n            });\n\n            loop {\n                let settings_changed = async {\n                    if settings_rx.changed().await.is_err() {\n                        std::future::pending::<()>().await;\n                    }\n                };\n                futures::select_biased! {\n                    outcome = (&mut response_rx).fuse() => {\n                        let outcome = outcome.map_err(|_| anyhow!(\"authorization channel closed\"))?;\n                        ensure_tool_call_authorization_not_interrupted(&outcome)?;\n                        return Self::handle_sandbox_permission_outcome(\n                            &outcome,\n                            &request,\n                            sandbox_grants.clone(),\n                            thread.clone(),\n                            fs.clone(),\n                            cx,\n                        );\n                    }\n                    _ = settings_changed.fuse() => {\n                        if cx.update(|cx| Self::sandbox_request_covered_by_grants(\n                            &request,\n                            &sandbox_grants,\n                            cx,\n                        )) {\n                            drop(response_rx);\n                            stream.resolve_tool_call_authorization(","sourceCodeStart":5874,"sourceCodeEnd":5910,"githubUrl":"https://github.com/zed-industries/zed/blob/bc538def4545534201bbfcac4e95ac34ea6501b6/crates/agent/src/thread.rs#L5874-L5910","documentation":"After sending a sandbox authorization request, the task awaits the user's answer on a oneshot channel; if that channel closes, 'authorization channel closed' is returned. The responder was dropped (prompt dismissed, client disconnected) without answering, so the permission outcome can never arrive.","triggerScenarios":"The authorization prompt is dismissed (UI closed, session ended, client dropped the request) while the thread waits on response_rx; any path where the response sender is dropped without sending an outcome.","commonSituations":"User closes the agent panel instead of answering; a client reload during a permission prompt; UI code that drops authorization requests on teardown instead of responding with a denial.","solutions":["Treat this error as a denial or cancellation and stop the tool call; do not retry the authorization","Ensure the UI always responds to ToolCallAuthorization events, including on dismissal","Keep the client session alive while any authorization request is pending","Cancel the thread before disconnecting so pending prompts resolve deterministically"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match permission_outcome {\n    Ok(decision) => apply(decision),\n    Err(err) if err.to_string() == \"authorization channel closed\" => {\n        // Prompt dismissed / client gone: behave like a denial.\n        abort_tool_call(\"authorization dismissed\");\n    }\n    Err(err) => return Err(err),\n}","preventionTips":["Ensure the UI always responds to ToolCallAuthorization events before dropping them","Respond with Deny on teardown instead of letting the response channel close","Keep the session alive while any authorization request is pending","Treat this error as cancellation, never retry the authorization automatically"],"tags":["rust","agent","sandbox","authorization","channel","cancellation"],"backgroundTag":null,"analyzedSha":"bc538def4545534201bbfcac4e95ac34ea6501b6","analyzedAt":"2026-08-16T07:30:46.435Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}