{"record":{"id":"e802aef38fe0feb1","repo":"xai-org/grok-build","slug":"failed-to-snapshot-into-upload-queue","errorCode":null,"errorMessage":"Failed to snapshot {} into upload queue","messagePattern":"Failed to snapshot (.+?) into upload queue","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/codegen/xai-file-utils/src/queue.rs","lineNumber":1209,"sourceCode":"                    let _ = tx.send(Err(anyhow::anyhow!(\n                        \"deduplicated: identical gcs_path already in flight\"\n                    )));\n                    return Ok(EnqueueResult {\n                        completion_rx: rx,\n                        original_size,\n                    });\n                }\n            }\n        } else {\n            None\n        };\n        let snapshot = self\n            .queue_dir\n            .join(temp_file_name(artifact_name, session_id, turn_number));\n        let disk_bytes = match reflink_copy::reflink_or_copy(source_path, &snapshot) {\n            Ok(copied) => copied.unwrap_or(0),\n            Err(e) => {\n                return Err(anyhow::Error::new(e).context(format!(\n                    \"Failed to snapshot {} into upload queue\",\n                    source_path.display()\n                )));\n            }\n        };\n        match check_snapshot(&snapshot, expected_sha256) {\n            SnapshotCheck::Match => {}\n            SnapshotCheck::Stale => {\n                try_remove_temp(&snapshot, Some(&self.stats));\n                self.stats.reference_stale.fetch_add(1, Ordering::Relaxed);\n                let _ = tx.send(Err(anyhow::anyhow!(\n                    \"reference snapshot did not match expected sha256; upload skipped\"\n                )));\n                return Ok(EnqueueResult {\n                    completion_rx: rx,\n                    original_size,\n                });\n            }","sourceCodeStart":1191,"sourceCodeEnd":1227,"githubUrl":"https://github.com/xai-org/grok-build/blob/bc7f02eddd3d84085849dc19ed216f11c23b0571/crates/codegen/xai-file-utils/src/queue.rs#L1191-L1227","documentation":"Raised when snapshotting an artifact into the upload queue fails: reflink_or_copy cannot copy source_path to the staged temp file in queue_dir. The underlying io error is wrapped with context naming the source path. It means the file never got staged, so no upload or integrity check occurs for that item.","triggerScenarios":"reflink_or_copy returns Err — source file missing/deleted mid-run, destination queue_dir missing or not writable, no permissions, cross-device copy failure, or disk full on the queue volume.","commonSituations":"Queue directory cleaned up by another process while uploads are in flight; artifact file already rotated/deleted by the tool that produced it; read-only or full disk on the queue volume; APFS/btrfs reflink unsupported and the copy fallback also failing.","solutions":["Verify source_path exists and is readable before snapshotting; re-create the artifact if it was deleted.","Ensure queue_dir exists with write permissions (create_dir_all + permission check).","Free disk space on the queue volume (this same error text will also surface ENOSPC from the copy).","Retry the snapshot; if it persists, upload the file directly (inline upload) bypassing the queue staging."],"exampleFix":"// before\nlet url = queue.snapshot_and_upload(source_path, artifact_name, expected).await?;\n// after\nif !source_path.exists() {\n    anyhow::bail!(\"artifact {} missing; regenerate before upload\", source_path.display());\n}\nlet url = match queue.snapshot_and_upload(source_path, artifact_name, expected).await {\n    Ok(u) => u,\n    Err(e) => {\n        tracing::warn!(%e, \"queue snapshot failed; uploading inline\");\n        inline_upload(source_path).await?\n    }\n};","handlingStrategy":"validation","validationCode":"fn snapshot_precheck(source: &Path, queue_dir: &Path) -> io::Result<()> {\n    if !source.is_file() { return Err(io::Error::new(io::ErrorKind::NotFound, \"source missing\")); }\n    std::fs::create_dir_all(queue_dir)?;\n    let probe = queue_dir.join(\".write_probe\");\n    std::fs::write(&probe, b\"\")?;\n    std::fs::remove_file(&probe)\n}","typeGuard":null,"tryCatchPattern":"match snapshot_into_queue(source, &queue_dir, name).await {\n    Ok(url) => url,\n    Err(e) if e.to_string().contains(\"Failed to snapshot\") => {\n        tracing::warn!(%e, \"staging failed; falling back to inline upload\");\n        inline_upload(source).await?\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Verify the artifact file exists and is readable immediately before upload","Ensure queue_dir exists, is writable, and has free space","Exclude queue_dir from external temp cleaners (tmpwatch/cron)","Call create_dir_all + a write probe during queue initialization"],"tags":["upload","filesystem","io","snapshot"],"backgroundTag":"file-copy-failed","analyzedSha":"bc7f02eddd3d84085849dc19ed216f11c23b0571","analyzedAt":"2026-08-31T04:59:42.031Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}