From a8554fdee3e0adf5909b93c425f2a03f14de6982 Mon Sep 17 00:00:00 2001 From: reidliu41 Date: Tue, 12 May 2026 18:37:40 +0800 Subject: [PATCH] fix(CI): validate pandoc output path before probing binary Validate binary pandoc target formats before checking whether pandoc is installed. This keeps invalid input errors stable on systems without pandoc and fixes the CI test that expects missing output_path to be reported first. --- crates/tui/src/tools/pandoc.rs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/crates/tui/src/tools/pandoc.rs b/crates/tui/src/tools/pandoc.rs index f7713280..636fbb79 100644 --- a/crates/tui/src/tools/pandoc.rs +++ b/crates/tui/src/tools/pandoc.rs @@ -127,6 +127,19 @@ impl ToolSpec for PandocConvertTool { ))); } + let resolved_output_path: Option = match output_path_str { + Some(p) => Some(context.resolve_path(p)?), + None => None, + }; + + // Binary formats can't round-trip through stdout reliably — + // require an output_path so the bytes survive the trip. + if resolved_output_path.is_none() && format_is_binary(&target_format) { + return Err(ToolError::invalid_input(format!( + "target_format `{target_format}` is binary; provide an `output_path` to write the converted file." + ))); + } + // Resolve the pandoc binary at execution time too — registration // gated on resolve_pandoc(), but a concurrent uninstall between // catalog build and the model's call should produce a clear @@ -141,19 +154,6 @@ impl ToolSpec for PandocConvertTool { ) })?; - let resolved_output_path: Option = match output_path_str { - Some(p) => Some(context.resolve_path(p)?), - None => None, - }; - - // Binary formats can't round-trip through stdout reliably — - // require an output_path so the bytes survive the trip. - if resolved_output_path.is_none() && format_is_binary(&target_format) { - return Err(ToolError::invalid_input(format!( - "target_format `{target_format}` is binary; provide an `output_path` to write the converted file." - ))); - } - let mut cmd = Command::new(&pandoc); cmd.arg(&source_path); cmd.arg("--to").arg(&target_format);