{"record":{"id":"7434f00d1e1b8ad0","repo":"jdx/mise","slug":"cannot-nest-relay-sessions","errorCode":null,"errorMessage":"cannot nest relay sessions","messagePattern":"cannot nest relay sessions","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cli/ssh.rs","lineNumber":155,"sourceCode":"                self.repository_dry_run,\n            )?;\n            return Ok(());\n        }\n        let scope = crate::github_relay::Scope::from_flags(\n            self.github_relay_read_only,\n            &self.github_relay_repo,\n            self.github_relay_all_repos,\n        )?;\n        let scope = crate::github_relay::configure(\n            scope,\n            self.github_relay_log_requests,\n            self.github_relay_no_log_requests,\n            self.github_relay_log_format.as_deref(),\n            self.github_relay_max_duration.as_deref(),\n        )?;\n        if let Some(socket) = self.relay_session {\n            if scope.is_some() {\n                bail!(\"cannot nest relay sessions\");\n            }\n            #[cfg(unix)]\n            {\n                crate::ui::ctrlc::exit_on_ctrl_c(false);\n                let mut command = self.command;\n                if let Some(first) = self.destination {\n                    command.insert(0, first);\n                }\n                return crate::system::remote::interruptible(crate::github_relay::unix::session(\n                    &socket, command,\n                ))\n                .await;\n            }\n            #[cfg(not(unix))]\n            bail!(\"GitHub relay requires a POSIX target: {}\", socket.display());\n        }\n        let destination = self\n            .destination","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/jdx/mise/blob/afd2eddd3a50c16190efc1c7e94404b48f72af57/src/cli/ssh.rs#L137-L173","documentation":"`mise ssh` (src/cli/ssh.rs:155) forbids opening a relay session from inside another relay session. When `--relay-session <socket>` is given and a relay `scope` is already active (inherited from an enclosing relayed command), nesting would create ambiguous socket/log routing, so run_inner bails.","triggerScenarios":"Running `mise ssh --relay-session <socket> ...` from within a command already executed under a relay scope, i.e. passing the relay-session flag while `scope` is Some.","commonSituations":"Shell profiles or wrappers that always inject `--relay-session` running inside an already-relayed SSH command; manually re-running a relayed command copy-pasted from a relayed shell; automation invoking mise ssh recursively over relay.","solutions":["Drop the `--relay-session` flag when already inside a relay session.","Run the nested command directly (outside the relayed environment) instead.","Guard wrapper scripts to only add `--relay-session` when no relay scope is active."],"exampleFix":"// before\nmise ssh host --relay-session /tmp/relay.sock  # run inside an existing relay session\n\n// after\nmise ssh host  # relay flag omitted inside an active relay scope","handlingStrategy":"validation","validationCode":"# skip relay flag when already inside a relay scope\nif [ -z \"$MISE_RELAY_SCOPE\" ]; then EXTRA=(--relay-session /tmp/relay.sock); fi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only pass --relay-session at the outermost command.","Detect an active relay scope in wrappers before adding the flag.","Avoid recursive mise ssh invocations over relay."],"tags":["ssh","relay","nesting","cli"],"backgroundTag":"invalid-state-transition","analyzedSha":"afd2eddd3a50c16190efc1c7e94404b48f72af57","analyzedAt":"2026-09-09T01:38:25.179Z","contentChangedAt":"2026-09-09T01:38:25.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}