From 6914f12209d550b15f5603fdbdf257c72a00d355 Mon Sep 17 00:00:00 2001 From: aiongg <67543387+aiongg@users.noreply.github.com> Date: Tue, 3 Nov 2026 19:08:01 +0000 Subject: [PATCH] Apply review fixes - crates/engine/src/script.rs --- crates/engine/src/script.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/engine/src/script.rs b/crates/engine/src/script.rs index 8b414f423..b8793121e 100644 --- a/crates/engine/src/script.rs +++ b/crates/engine/src/script.rs @@ -51,7 +51,7 @@ pub fn parse(text: &str) -> Result, String> { let (id, rest) = l.split_at(split); let rest = rest.trim_start_matches(['=', ' ', '\t']).trim(); let params = if rest.is_empty() { Ok(json!({})) } else { serde_json::from_str(rest).map_err(|e| e.to_string()) }; - params.and_then(|params: Value| { + params.map(|p: Value| if p.is_null() { json!({}) } else { p }).and_then(|params: Value| { if params.is_object() { Ok(Step { command: id.to_string(), params }) } else { Err("`params` must be an object".to_string()) } }) }; @@ -199,10 +199,11 @@ mod tests { #[test] fn compact_lines_require_object_params() { - for bad in ["a.b 5", "a.b [1]", "a.b \"x\"", "a.b=true", "a.b null"] { + for bad in ["a.b 5", "a.b [1]", "a.b \"x\"", "a.b=true"] { assert_eq!(parse(bad), Err("line 1: `params` must be an object".to_string()), "{bad}"); } assert_eq!(parse("\na.b={\"x\":1}").unwrap()[0].params, json!({"x": 1})); + assert_eq!(parse("a.b null").unwrap()[0].params, json!({})); } /// Windows editors and PowerShell 5.1 save "UTF-8 with BOM" with CRLF line endings; the BOM