From ba3b57c756d57f21874e9a3ed075cbd3ce195b52 Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Mon, 2 Nov 2026 23:07:24 -0500 Subject: [PATCH] file.export: a perPage that isn't a count is refused, not read as 6 Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/cmd/file.rs | 2 +- crates/engine/src/tests.rs | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/engine/src/cmd/file.rs b/crates/engine/src/cmd/file.rs index dc9f1a44e..7857535c0 100644 --- a/crates/engine/src/cmd/file.rs +++ b/crates/engine/src/cmd/file.rs @@ -360,7 +360,7 @@ pub fn pdf_options(p: &Value, count: usize) -> Result o.layout = match str_param(p, "layout").unwrap_or("slides") { "notes" => deckcraft_pdf::PageLayout::Notes, "handouts" => { - let per_page = usize_param(p, "perPage").unwrap_or(6); + let per_page = opt_usize_param(p, "perPage", "file.export")?.unwrap_or(6); if ![1, 2, 3, 4, 6, 9].contains(&per_page) { return Err(bad("file.export", format!("perPage {per_page} isn't one of 1, 2, 3, 4, 6, 9"))); } diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index e8038c9a2..1c8e7a8ac 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -2421,6 +2421,10 @@ fn pdf_options_reject_unsupported_per_page() { let e = cmd::file::pdf_options(&json!({"layout": "handouts", "perPage": n}), 1).unwrap_err(); assert!(e.to_string().contains("1, 2, 3, 4, 6, 9"), "perPage {n}: {e}"); } + // Not a count at all: refused too, instead of falling back to 6. + for v in [json!(-1), json!(5.5), json!("6")] { + assert!(cmd::file::pdf_options(&json!({"layout": "handouts", "perPage": v}), 1).is_err(), "perPage {v}"); + } } #[test]