From ca2c71fb703bd72cadd28fe900f341589bab10df Mon Sep 17 00:00:00 2001 From: kdesjard Date: Tue, 12 Dec 2023 11:35:50 +0000 Subject: [PATCH 1/2] convert unwrap to unwrap_or and provide default empty string for an unwrap that gets hit whenever a job exits without any output Signed-off-by: kdesjard --- src/engine/dag.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/dag.rs b/src/engine/dag.rs index d890520..1408823 100644 --- a/src/engine/dag.rs +++ b/src/engine/dag.rs @@ -330,7 +330,7 @@ impl Dag { "Execution failed [name: {}, id: {}]\nerr: {}", task_name, task_id, - out.get_err().unwrap() + out.get_err().unwrap_or("".to_string()) ); false } else { From 0bb9471477b1c23664d3a2c46242feaa8d357553 Mon Sep 17 00:00:00 2001 From: kdesjard Date: Tue, 12 Dec 2023 11:36:43 +0000 Subject: [PATCH 2/2] convert an unwrap to use ParseError Signed-off-by: kdesjard --- src/yaml/yaml_parser.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/yaml/yaml_parser.rs b/src/yaml/yaml_parser.rs index cda037e..8e1076f 100644 --- a/src/yaml/yaml_parser.rs +++ b/src/yaml/yaml_parser.rs @@ -1,6 +1,6 @@ //! Default yaml configuration file parser. -use super::{FileContentError, FileNotFound, YamlTask, YamlTaskError}; +use super::{FileContentError, YamlTask, YamlTaskError}; use crate::{utils::ParseError, Action, CommandAction, Parser, Task, utils::file::load_file}; use std::{collections::HashMap, sync::Arc}; use yaml_rust::{Yaml, YamlLoader}; @@ -81,7 +81,7 @@ impl Parser for YamlParser { let mut map = HashMap::with_capacity(yaml_tasks.len()); // Read tasks for (v, w) in yaml_tasks { - let id = v.as_str().unwrap(); + let id = v.as_str().ok_or(ParseError("Invalid YAML Node Type".to_string()))?; let task = specific_actions.remove(id).map_or_else( || self.parse_one(id, w, None), |action| self.parse_one(id, w, Some(action)),