From 4097ac0131a5cf4f6ce9db675aa2e8c54482d93e Mon Sep 17 00:00:00 2001 From: bherbruck Date: Thu, 15 Oct 2026 19:12:55 -0400 Subject: [PATCH] sketch.cut: refuse non-object params instead of panicking --- crates/engine/src/cmd/sketch_clipboard.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/engine/src/cmd/sketch_clipboard.rs b/crates/engine/src/cmd/sketch_clipboard.rs index 5818063c..b8036f93 100644 --- a/crates/engine/src/cmd/sketch_clipboard.rs +++ b/crates/engine/src/cmd/sketch_clipboard.rs @@ -209,8 +209,12 @@ fn copy(s: &mut Session, p: &Value) -> Result { } fn cut(s: &mut Session, p: &Value) -> Result { + // `q["entities"] = …` below panics on anything but an object. + if !(p.is_object() || p.is_null()) { + return Err(bad("sketch.cut", "params must be an object")); + } let entities = chosen(s, p); - let mut q = p.clone(); + let mut q = if p.is_null() { json!({}) } else { p.clone() }; q["entities"] = json!(entities); let out = copy(s, &q)?; let delete = super::find_command("sketch.delete").ok_or_else(|| bad("sketch.cut", "sketch.delete is missing"))?;