{"record":{"id":"f9708293f8fd0392","repo":"openai/codex","slug":"escalate-socket-env-var-is-not-a-valid-file-desc","errorCode":null,"errorMessage":"{ESCALATE_SOCKET_ENV_VAR} is not a valid file descriptor: {client_fd}","messagePattern":"(.+?) is not a valid file descriptor: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"codex-rs/shell-escalation/src/unix/escalate_client.rs","lineNumber":23,"sourceCode":"\nuse anyhow::Context as _;\nuse codex_utils_absolute_path::AbsolutePathBuf;\n\nuse crate::unix::escalate_protocol::ESCALATE_SOCKET_ENV_VAR;\nuse crate::unix::escalate_protocol::EXEC_WRAPPER_ENV_VAR;\nuse crate::unix::escalate_protocol::EscalateAction;\nuse crate::unix::escalate_protocol::EscalateRequest;\nuse crate::unix::escalate_protocol::EscalateResponse;\nuse crate::unix::escalate_protocol::SuperExecMessage;\nuse crate::unix::escalate_protocol::SuperExecResult;\nuse crate::unix::socket::AsyncDatagramSocket;\nuse crate::unix::socket::AsyncSocket;\n\nfn get_escalate_client() -> anyhow::Result<AsyncDatagramSocket> {\n    // TODO: we should defensively require only calling this once, since AsyncSocket will take ownership of the fd.\n    let client_fd = std::env::var(ESCALATE_SOCKET_ENV_VAR)?.parse::<i32>()?;\n    if client_fd < 0 {\n        return Err(anyhow::anyhow!(\n            \"{ESCALATE_SOCKET_ENV_VAR} is not a valid file descriptor: {client_fd}\"\n        ));\n    }\n    Ok(unsafe { AsyncDatagramSocket::from_raw_fd(client_fd) }?)\n}\n\nfn duplicate_fd_for_transfer(fd: impl AsFd, name: &str) -> anyhow::Result<OwnedFd> {\n    fd.as_fd()\n        .try_clone_to_owned()\n        .with_context(|| format!(\"failed to duplicate {name} for escalation transfer\"))\n}\n\npub async fn run_shell_escalation_execve_wrapper(\n    file: String,\n    argv: Vec<String>,\n) -> anyhow::Result<i32> {\n    let handshake_client = get_escalate_client()?;\n    let (server, client) = AsyncSocket::pair()?;","sourceCodeStart":5,"sourceCodeEnd":41,"githubUrl":"https://github.com/openai/codex/blob/339751715c64496cb86246bfb3935f40e309dd3d/codex-rs/shell-escalation/src/unix/escalate_client.rs#L5-L41","documentation":"Error \"{ESCALATE_SOCKET_ENV_VAR} is not a valid file descriptor: {client_fd}\" thrown in openai/codex.","triggerScenarios":"Thrown at codex-rs/shell-escalation/src/unix/escalate_client.rs:23 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"339751715c64496cb86246bfb3935f40e309dd3d","analyzedAt":"2026-08-25T05:35:09.876Z","schemaVersion":2},"datasetVersion":"2026-08-25T06:17:31.827Z"}