{"record":{"id":"1e0e9c73dd53aeb6","repo":"xai-org/grok-build","slug":"failed-to-read-clipboard-temp-file-e","errorCode":null,"errorMessage":"failed to read clipboard temp file: {e}","messagePattern":"failed to read clipboard temp file: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codegen/xai-grok-shared/src/clipboard.rs","lineNumber":820,"sourceCode":"        path_tiff: &std::path::Path,\n        path_jpg: &std::path::Path,\n    ) -> anyhow::Result<Option<ImageData>> {\n        let (temp_path, mime) = match class {\n            \"PNGf\" => (path_png, \"image/png\"),\n            \"TIFF\" => (path_tiff, \"image/tiff\"),\n            \"JPEG\" => (path_jpg, \"image/jpeg\"),\n            _ => return Ok(None),\n        };\n\n        let data = match std::fs::read(temp_path) {\n            Ok(bytes) if !bytes.is_empty() => bytes,\n            Ok(_) => {\n                let _ = std::fs::remove_file(temp_path);\n                return Ok(None);\n            }\n            Err(e) => {\n                let _ = std::fs::remove_file(temp_path);\n                return Err(anyhow::anyhow!(\"failed to read clipboard temp file: {e}\"));\n            }\n        };\n\n        let _ = std::fs::remove_file(temp_path);\n        Ok(Some(ImageData {\n            data,\n            mime_type: mime.to_owned(),\n        }))\n    }\n\n    fn remove_attachment_probe_temps(\n        path_png: &std::path::Path,\n        path_tiff: &std::path::Path,\n        path_jpg: &std::path::Path,\n    ) {\n        let _ = std::fs::remove_file(path_png);\n        let _ = std::fs::remove_file(path_tiff);\n        let _ = std::fs::remove_file(path_jpg);","sourceCodeStart":802,"sourceCodeEnd":838,"githubUrl":"https://github.com/xai-org/grok-build/blob/bc7f02eddd3d84085849dc19ed216f11c23b0571/crates/codegen/xai-grok-shared/src/clipboard.rs#L802-L838","documentation":"read_clipboard_image_from_class (crates/codegen/xai-grok-shared/src/clipboard.rs:820) dumps the clipboard image to a temp file and reads it back; if std::fs::read fails it returns this error after cleaning up the temp file. The clipboard access itself succeeded — the failure is in filesystem I/O on the temp path.","triggerScenarios":"get_image / get_attachments on Linux (X11 class-based read) where the temp file was deleted concurrently, the temp dir is unwritable/read-protected, or the disk is full between write and read.","commonSituations":"See trigger scenarios.","solutions":["Check TMPDIR points to an existing, writable directory (`ls -ld $TMPDIR /tmp`).","Rule out external cleaners (systemd-tmpfiles, antivirus) deleting the file mid-flight.","Ensure no concurrent processes share/collide on the same temp file path.","Free disk space if the filesystem is full."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"fn temp_dir_writable() -> bool {\n    std::env::temp_dir().metadata().map(|m| m.is_dir()).unwrap_or(false)\n}","typeGuard":null,"tryCatchPattern":"match get_image() {\n    Err(e) if e.to_string().contains(\"failed to read clipboard temp file\") => {\n        eprintln!(\"temp file I/O problem: {e}\");\n        Ok(None)\n    }\n    other => other,\n}","preventionTips":["Ensure TMPDIR exists and is writable before clipboard image reads.","Avoid temp-file cleaners racing with short-lived clipboard temp files.","Don't share one temp path across concurrent readers."],"tags":["clipboard","filesystem","temp-file"],"backgroundTag":"temp-file-read-failed","analyzedSha":"bc7f02eddd3d84085849dc19ed216f11c23b0571","analyzedAt":"2026-08-31T04:59:42.031Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}