From 609ac53c3fd7d588f6fdebb519b21bc52c498f7c Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sat, 28 Feb 2026 21:50:45 +0300 Subject: [PATCH] fc-queue-server: match output names by path instead of index Now creates a path-to-name lookup `HashMap` from the outputs JSON and matches each output path to its correct name. Both the `build_outputs` table insert and GC root registration loops now use the same lookup to ensure we're consistent. Signed-off-by: NotAShelf Change-Id: Id9f4ce0be6131a7c1a8ce6775ab249db6a6a6964 --- crates/queue-runner/src/worker.rs | 49 ++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/crates/queue-runner/src/worker.rs b/crates/queue-runner/src/worker.rs index ed852ad..d1bc6b9 100644 --- a/crates/queue-runner/src/worker.rs +++ b/crates/queue-runner/src/worker.rs @@ -588,23 +588,35 @@ async fn run_build( }; if build_result.success { - // Parse output names from build's outputs JSON - let output_names: Vec = build + // Build a reverse lookup map: path -> output_name + // The outputs JSON is a HashMap where keys are output names + // and values are store paths. We need to match paths to names correctly. + let path_to_name: std::collections::HashMap = build .outputs .as_ref() .and_then(|v| v.as_object()) - .map(|obj| obj.keys().cloned().collect()) + .map(|obj| { + obj + .iter() + .filter_map(|(name, path)| { + path.as_str().map(|p| (p.to_string(), name.clone())) + }) + .collect() + }) .unwrap_or_default(); // Store build outputs in normalized table for (i, output_path) in build_result.output_paths.iter().enumerate() { - let output_name = output_names.get(i).cloned().unwrap_or_else(|| { - if i == 0 { - "out".to_string() - } else { - format!("out{i}") - } - }); + let output_name = path_to_name + .get(output_path) + .cloned() + .unwrap_or_else(|| { + if i == 0 { + "out".to_string() + } else { + format!("out{i}") + } + }); if let Err(e) = repo::build_outputs::create( pool, @@ -624,13 +636,16 @@ async fn run_build( // Register GC roots and create build products for each output for (i, output_path) in build_result.output_paths.iter().enumerate() { - let output_name = output_names.get(i).cloned().unwrap_or_else(|| { - if i == 0 { - build.job_name.clone() - } else { - format!("{}-{i}", build.job_name) - } - }); + let output_name = path_to_name + .get(output_path) + .cloned() + .unwrap_or_else(|| { + if i == 0 { + build.job_name.clone() + } else { + format!("{}-{i}", build.job_name) + } + }); // Register GC root let mut gc_root_path = None;