xai-org/grok-build · error · anyhow::Error
Failed to snapshot into upload queue
Error message
Failed to snapshot {} into upload queue What it means
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.
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.
Example fix
// before
let url = queue.snapshot_and_upload(source_path, artifact_name, expected).await?;
// after
if !source_path.exists() {
anyhow::bail!("artifact {} missing; regenerate before upload", source_path.display());
}
let url = match queue.snapshot_and_upload(source_path, artifact_name, expected).await {
Ok(u) => u,
Err(e) => {
tracing::warn!(%e, "queue snapshot failed; uploading inline");
inline_upload(source_path).await?
}
}; Defensive patterns
Strategy: validation
Validate before calling
fn snapshot_precheck(source: &Path, queue_dir: &Path) -> io::Result<()> {
if !source.is_file() { return Err(io::Error::new(io::ErrorKind::NotFound, "source missing")); }
std::fs::create_dir_all(queue_dir)?;
let probe = queue_dir.join(".write_probe");
std::fs::write(&probe, b"")?;
std::fs::remove_file(&probe)
} Try / catch
match snapshot_into_queue(source, &queue_dir, name).await {
Ok(url) => url,
Err(e) if e.to_string().contains("Failed to snapshot") => {
tracing::warn!(%e, "staging failed; falling back to inline upload");
inline_upload(source).await?
}
Err(e) => return Err(e),
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Failed to hash snapshot
- Compaction checkpoint file missing
- could not reserve a unique
- failed to create BTRFS snapshot from
- failed to create chrome trace
AI-assisted analysis of xai-org/grok-build@bc7f02eddd (2026-08-31).
Data as JSON: /api/errors/e802aef38fe0feb1.
Report an issue: GitHub.
Appendix: source
Thrown at crates/codegen/xai-file-utils/src/queue.rs:1209
let _ = tx.send(Err(anyhow::anyhow!(
"deduplicated: identical gcs_path already in flight"
)));
return Ok(EnqueueResult {
completion_rx: rx,
original_size,
});
}
}
} else {
None
};
let snapshot = self
.queue_dir
.join(temp_file_name(artifact_name, session_id, turn_number));
let disk_bytes = match reflink_copy::reflink_or_copy(source_path, &snapshot) {
Ok(copied) => copied.unwrap_or(0),
Err(e) => {
return Err(anyhow::Error::new(e).context(format!(
"Failed to snapshot {} into upload queue",
source_path.display()
)));
}
};
match check_snapshot(&snapshot, expected_sha256) {
SnapshotCheck::Match => {}
SnapshotCheck::Stale => {
try_remove_temp(&snapshot, Some(&self.stats));
self.stats.reference_stale.fetch_add(1, Ordering::Relaxed);
let _ = tx.send(Err(anyhow::anyhow!(
"reference snapshot did not match expected sha256; upload skipped"
)));
return Ok(EnqueueResult {
completion_rx: rx,
original_size,
});
}View on GitHub (pinned to bc7f02eddd)