{"record":{"id":"c38a3914b35f3bdd","repo":"warpdotdev/warp","slug":"failed-to-write-temp-file-prefix-e","errorCode":null,"errorMessage":"Failed to write temp file '{prefix}': {e}","messagePattern":"Failed to write temp file '(.+?)': (.+?)","errorType":"exception","errorClass":"AgentDriverError::ConfigBuildFailed","httpStatus":null,"severity":"error","filePath":"app/src/ai/agent_sdk/driver/harness/mod.rs","lineNumber":580,"sourceCode":"///\n/// Used by third-party harnesses to stage prompts / system prompts on disk\n/// before launching the CLI, avoiding shell-quoting issues with complex input.\npub(super) fn write_temp_file(\n    prefix: &str,\n    content: &str,\n    suffix: &str,\n) -> Result<NamedTempFile, AgentDriverError> {\n    let mut file = tempfile::Builder::new()\n        .prefix(prefix)\n        .suffix(suffix)\n        .tempfile()\n        .map_err(|e| {\n            AgentDriverError::ConfigBuildFailed(anyhow::anyhow!(\n                \"Failed to create temp file '{prefix}': {e}\"\n            ))\n        })?;\n    file.write_all(content.as_bytes()).map_err(|e| {\n        AgentDriverError::ConfigBuildFailed(anyhow::anyhow!(\n            \"Failed to write temp file '{prefix}': {e}\"\n        ))\n    })?;\n    Ok(file)\n}\n\n/// Upload a [`SerializedBlock`] as the JSON block snapshot for a third-party harness conversation.\npub(crate) async fn upload_block_snapshot(\n    client: &dyn HarnessSupportClient,\n    conversation_id: AIConversationId,\n    block: SerializedBlock,\n) -> Result<()> {\n    log::info!(\"Uploading block snapshot for CLI agent to conversation {conversation_id}\");\n    let target = client\n        .get_block_snapshot_upload_target(&conversation_id)\n        .await\n        .with_context(|| {\n            format!(\"Unable to get block upload slot for conversation {conversation_id}\")","sourceCodeStart":562,"sourceCodeEnd":598,"githubUrl":"https://github.com/warpdotdev/warp/blob/e72fd7aacbbb2236d9b3be2aad7e7178fe94b4bc/app/src/ai/agent_sdk/driver/harness/mod.rs#L562-L598","documentation":"Wrapped as AgentDriverError::ConfigBuildFailed when write_all on the just-created NamedTempFile fails. Creation succeeded, so this is a mid-write failure: ENOSPC when the disk fills while writing the prompt content, EIO on failing storage, or the temp file being invalidated (dir cleanup races, sandbox revocation).","triggerScenarios":"Calling write_temp_file with large prompt/system-prompt content on a nearly-full disk — the create succeeds, then write_all hits ENOSPC partway; also flaky network-backed temp mounts (NFS /tmp) or macOS periodic tmp cleaners racing the write.","commonSituations":"Very large system prompts or context dumps exhausting remaining disk; CI containers with small overlay filesystems; temp dirs on network storage that drops mid-write.","solutions":["Free temp-directory disk space (df -h $TMPDIR) and retry — ENOSPC is the dominant cause given creation already succeeded.","Move TMPDIR to a volume with ample free space for prompt-sized writes.","If using network-backed /tmp, switch to local storage to avoid EIO/flush failures mid-write."],"exampleFix":"# before\n# disk nearly full: tempfile created, write_all fails with ENOSPC\nwarp agent run …\n\n# after\ndf -h /tmp && docker system prune -a   # or: export TMPDIR=/data/tmp with free space\nwarp agent run …","handlingStrategy":"try-catch","validationCode":"let needed = content.len() as u64 + 1024;\nlet avail = fs2::available_space(&std::env::temp_dir())?;\nanyhow::ensure!(avail > needed, \"temp dir needs ~{} bytes free for prompt staging\", needed);","typeGuard":null,"tryCatchPattern":"match write_temp_file(prefix, content, suffix) {\n    Err(AgentDriverError::ConfigBuildFailed(err)) if err.to_string().contains(\"Failed to write temp file\") => {\n        // ENOSPC mid-write: free space or switch TMPDIR, then retry once\n        std::env::set_var(\"TMPDIR\", alternate_dir_with_space());\n        write_temp_file(prefix, content, suffix)\n    }\n    rest => rest,\n}","preventionTips":["Keep temp volume headroom larger than the largest prompt/system prompt you stage.","Prefer local disk over NFS-backed /tmp for temp files to avoid mid-write EIO.","Since creation succeeded but the write failed, suspect ENOSPC first and check df -h $TMPDIR."],"tags":["filesystem","temp-files","io","disk-full","rust"],"backgroundTag":null,"analyzedSha":"e72fd7aacbbb2236d9b3be2aad7e7178fe94b4bc","analyzedAt":"2026-08-16T08:27:25.381Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}