From 9fd4350c57bbe986ebf65bf3ea4c996572e81884 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Fri, 23 Jan 2026 09:18:13 +0000 Subject: fix: improve 'not our ref' error messages and warn about multi-OID fetch bug When git fetch fails with 'upload-pack: not our ref', git stops at the first missing OID and doesn't attempt to fetch remaining OIDs. This means if we request 5 OIDs and the first is missing, we never try the other 4 (which may exist on the remote). Changes: - Parse missing OID from stderr for clearer error messages - Single OID case: 'remote missing only oid requested: ' - Multi OID case: Log WARNING and indicate other OIDs weren't attempted - Identifies the bug that needs retry logic to fetch OIDs individually --- src/purgatory/sync/context.rs | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/src/purgatory/sync/context.rs b/src/purgatory/sync/context.rs index f41dc25..33c2d12 100644 --- a/src/purgatory/sync/context.rs +++ b/src/purgatory/sync/context.rs @@ -408,7 +408,45 @@ impl SyncContext for RealSyncContext { } } - Err(anyhow::anyhow!("git fetch failed: {}", stderr)) + // Check for "not our ref" errors and provide a clearer error message + let error_msg = if stderr.contains("upload-pack: not our ref") { + // Parse out the missing OID from stderr (git only reports one at a time) + let missing_oid = stderr + .lines() + .find_map(|line| { + if line.contains("not our ref") { + // Extract the OID from lines like: + // "fatal: remote error: upload-pack: not our ref " + line.split("not our ref").nth(1).map(|s| s.trim().to_string()) + } else { + None + } + }); + + let total_requested = missing_oids.len(); + + if let Some(oid) = missing_oid { + if total_requested > 1 { + // BUG: Git stops at first missing OID, so we don't know if the others exist + // We need retry logic to fetch remaining OIDs individually + tracing::warn!( + url = %url, + missing_oid = %oid, + total_requested = total_requested, + "Git fetch failed on first missing OID - other requested OIDs may exist but were not fetched. Retry logic needed." + ); + format!("remote missing oid {} (BUG: {} other oids not attempted)", oid, total_requested - 1) + } else { + format!("remote missing only oid requested: {}", oid) + } + } else { + format!("git fetch failed: {}", stderr) + } + } else { + format!("git fetch failed: {}", stderr) + }; + + Err(anyhow::anyhow!("{}", error_msg)) } Err(e) => Err(anyhow::anyhow!("git fetch command error: {}", e)), } -- cgit v1.2.3