{"record":{"id":"9e084720e386321a","repo":"openai/codex","slug":"writefile-failed-err","errorCode":null,"errorMessage":"WriteFile failed: {err}","messagePattern":"WriteFile failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"codex-rs/windows-sandbox-rs/src/unified_exec/backends/legacy.rs","lineNumber":227,"sourceCode":"        }\n    }\n}\n\nfn write_all_handle(handle: HANDLE, mut bytes: &[u8]) -> Result<()> {\n    while !bytes.is_empty() {\n        let mut written = 0u32;\n        let ok = unsafe {\n            WriteFile(\n                handle,\n                bytes.as_ptr() as *const _,\n                bytes.len() as u32,\n                &mut written,\n                ptr::null_mut(),\n            )\n        };\n        if ok == 0 {\n            let err = unsafe { GetLastError() } as i32;\n            return Err(anyhow::anyhow!(\"WriteFile failed: {err}\"));\n        }\n        if written == 0 {\n            anyhow::bail!(\"WriteFile returned success but wrote 0 bytes\");\n        }\n        bytes = &bytes[written as usize..];\n    }\n    Ok(())\n}\n\n#[allow(clippy::too_many_arguments)]\nfn finalize_exit(\n    exit_tx: oneshot::Sender<i32>,\n    process_handle: Arc<StdMutex<Option<HANDLE>>>,\n    thread_handle: HANDLE,\n    output_join: std::thread::JoinHandle<()>,\n    logs_base_dir: Option<&Path>,\n    command: Vec<String>,\n) {","sourceCodeStart":209,"sourceCodeEnd":245,"githubUrl":"https://github.com/openai/codex/blob/339751715c64496cb86246bfb3935f40e309dd3d/codex-rs/windows-sandbox-rs/src/unified_exec/backends/legacy.rs#L209-L245","documentation":"Error \"WriteFile failed: {err}\" thrown in openai/codex.","triggerScenarios":"Thrown at codex-rs/windows-sandbox-rs/src/unified_exec/backends/legacy.rs:227 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check that the pipe to the process is still open (the process may have exited) and inspect the inner Win32 error; retry the write."],"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"}