Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: output_path and derivation_path may be null or false #38

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
## [Unreleased]
### Added
- [#34](https://github.com/tweag/nixtract/pull/34) add option to provide nixtract with a status communication channel

### Fixed
- [#38](https://github.com/tweag/nixtract/pull/38) fixed bug where found derivations were parsed incorrectly
31 changes: 18 additions & 13 deletions src/nix/find_attribute_paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>,
/// 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<String>,
}

pub fn find_attribute_paths(
Expand Down Expand Up @@ -71,23 +75,24 @@ pub fn find_attribute_paths(
let mut res: Vec<AttributePaths> = 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
);
}
};
}
}

Expand Down
Loading