mirror of
https://github.com/storytold/lightcraft.git
synced 2026-11-01 14:07:34 -06:00
Merge PR #3122: LC-002: reject non-object script parameters
This commit is contained in:
@@ -567,7 +567,11 @@ fn run(args: &[String]) -> Result<(), String> {
|
||||
.or(v.get("method"))
|
||||
.and_then(Value::as_str)
|
||||
.ok_or_else(|| format!("{path}:{}: needs `command` or `method`", n + 1))?;
|
||||
let params = v.get("params").cloned().filter(|p| p.is_object()).unwrap_or_else(|| json!({}));
|
||||
let params = match v.get("params") {
|
||||
None | Some(Value::Null) => json!({}),
|
||||
Some(Value::Object(params)) => Value::Object(params.clone()),
|
||||
Some(_) => return Err(format!("{path}:{}: `params` must be a JSON object", n + 1)),
|
||||
};
|
||||
steps.push(Step { id: id.to_string(), params });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user