CLI: a failed render under run/exec exits 1, like render --queue (part of #1426)

This commit is contained in:
Marco Arnulfo
2026-10-14 13:47:08 +02:00
parent 549e9d8251
commit e26dd21af7
2 changed files with 47 additions and 0 deletions
+21
View File
@@ -493,6 +493,9 @@ fn run(cmd: &str, args: &Args, json_out: bool) -> Result<(), Failure> {
};
let mut b = backend(args, true)?;
let r = b.exec(&id, params)?;
if let Some(e) = failed_render(&id, &r) {
return Err(Failure::Error(e));
}
let saved = maybe_save(&mut b, args)?;
emit(&with_saved(r, saved), json_out);
}
@@ -515,6 +518,9 @@ fn run(cmd: &str, args: &Args, json_out: bool) -> Result<(), Failure> {
};
i += 1;
let r = b.exec(id, params).map_err(|e| Failure::Error(format!("{id}: {e}")))?;
if let Some(e) = failed_render(id, &r) {
return Err(Failure::Error(format!("{id}: {e}")));
}
if !json_out {
emit(&r, false);
}
@@ -637,6 +643,21 @@ fn positional<const N: usize>(args: &Args, usage: &str) -> Result<[String; N], F
Ok(std::array::from_fn(|i| args.pos[i].clone()))
}
/// `renderQueue.render` reports a failed item in its result, not as an error. Under `run`/`exec`
/// that item fails the command (#1426), as it fails `render --queue`.
fn failed_render(id: &str, r: &Value) -> Option<String> {
if id != "renderQueue.render" {
return None;
}
let failed: Vec<String> = r["items"]
.as_array()
.into_iter()
.flatten()
.filter_map(|i| Some(format!("{}: {}", i["compName"].as_str().unwrap_or("?"), i["status"].get("Failed")?.as_str().unwrap_or("failed"))))
.collect();
(!failed.is_empty()).then(|| failed.join("; "))
}
fn with_saved(v: Value, saved: Option<String>) -> Value {
match saved {
None => v,