From c3c1dfc0e4a368d8f4b382c627a9d763e6ec79d2 Mon Sep 17 00:00:00 2001 From: Erin van der Veen Date: Thu, 14 Mar 2024 10:17:50 +0100 Subject: [PATCH] fix: output_path and derivation_path may be null or false --- src/nix/find_attribute_paths.rs | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/src/nix/find_attribute_paths.rs b/src/nix/find_attribute_paths.rs index df074b8..9f184b5 100644 --- a/src/nix/find_attribute_paths.rs +++ b/src/nix/find_attribute_paths.rs @@ -15,8 +15,12 @@ pub struct AttributePaths { #[serde(rename_all = "camelCase")] pub struct FoundDrv { pub attribute_path: String, - pub derivation_path: String, - pub output_path: String, + /// drv path of the derivation + /// We discard any values that are not null or String, which occasionally occur (namely false) + pub derivation_path: Option, + /// The output path of the derivation + /// We discard any values that are not null or String, which occasionally occur (namely false) + pub output_path: Option, } pub fn find_attribute_paths( @@ -71,23 +75,24 @@ pub fn find_attribute_paths( let mut res: Vec = Vec::new(); for line in stderr.lines() { + log::info!("find_attribute_paths line: {}", line); + if !line.starts_with("trace: ") { log::warn!( "Unexpected output from nix command, attempting to continue: {}", line ); } else { - let attribute_paths: AttributePaths = - match serde_json::from_str(line.trim_start_matches("trace: ")) { - Ok(attribute_paths) => attribute_paths, - Err(e) => { - return Err(Error::SerdeJSON( - attribute_path.clone().unwrap_or_default(), - e, - )) - } - }; - res.push(attribute_paths); + match serde_json::from_str(line.trim_start_matches("trace: ")) { + Ok(attribute_paths) => res.push(attribute_paths), + Err(e) => { + log::warn!( + "Error parsing found_derivation output: {} {}. Attempting to continue...", + attribute_path.clone().unwrap_or_default(), + e + ); + } + }; } }