From 29dd4289ea801c988b45af7aa78fd398da968d28 Mon Sep 17 00:00:00 2001 From: Felippe Costa Date: Sun, 8 Feb 2026 13:28:34 -0300 Subject: [PATCH 1/2] fix: improve error message when sidecar and media arguments are swapped --- src/bin/signedshot.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/bin/signedshot.rs b/src/bin/signedshot.rs index 3749fd5..d738b73 100644 --- a/src/bin/signedshot.rs +++ b/src/bin/signedshot.rs @@ -84,6 +84,16 @@ fn validate_command(sidecar_path: &Path, media_path: &Path, json_output: bool) - s } Err(e) => { + let err_msg = format!("{}", e); + if err_msg.contains("valid UTF-8") || err_msg.contains("expected value") { + let ext = sidecar_path.extension().and_then(|e| e.to_str()).unwrap_or(""); + if matches!(ext, "jpg" | "jpeg" | "png" | "heic" | "heif" | "mp4" | "mov") { + eprintln!("[FAILED] The sidecar path appears to be a media file, not a JSON sidecar."); + eprintln!(" Did you swap the arguments?"); + eprintln!(" Usage: signedshot validate "); + return Err(anyhow::anyhow!("Arguments appear to be swapped: sidecar path '{}' looks like a media file", sidecar_path.display())); + } + } println!("[FAILED] Sidecar parsing: {}", e); return Err(e).context("Failed to parse sidecar"); } From ec0178aa15ac21cb0829efba6acdb6fd5b359126 Mon Sep 17 00:00:00 2001 From: Felippe Costa Date: Sun, 8 Feb 2026 13:42:38 -0300 Subject: [PATCH 2/2] style: fix rustfmt formatting Co-Authored-By: Claude Opus 4.6 --- src/bin/signedshot.rs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/bin/signedshot.rs b/src/bin/signedshot.rs index d738b73..0ee865a 100644 --- a/src/bin/signedshot.rs +++ b/src/bin/signedshot.rs @@ -86,12 +86,23 @@ fn validate_command(sidecar_path: &Path, media_path: &Path, json_output: bool) - Err(e) => { let err_msg = format!("{}", e); if err_msg.contains("valid UTF-8") || err_msg.contains("expected value") { - let ext = sidecar_path.extension().and_then(|e| e.to_str()).unwrap_or(""); - if matches!(ext, "jpg" | "jpeg" | "png" | "heic" | "heif" | "mp4" | "mov") { - eprintln!("[FAILED] The sidecar path appears to be a media file, not a JSON sidecar."); + let ext = sidecar_path + .extension() + .and_then(|e| e.to_str()) + .unwrap_or(""); + if matches!( + ext, + "jpg" | "jpeg" | "png" | "heic" | "heif" | "mp4" | "mov" + ) { + eprintln!( + "[FAILED] The sidecar path appears to be a media file, not a JSON sidecar." + ); eprintln!(" Did you swap the arguments?"); eprintln!(" Usage: signedshot validate "); - return Err(anyhow::anyhow!("Arguments appear to be swapped: sidecar path '{}' looks like a media file", sidecar_path.display())); + return Err(anyhow::anyhow!( + "Arguments appear to be swapped: sidecar path '{}' looks like a media file", + sidecar_path.display() + )); } } println!("[FAILED] Sidecar parsing: {}", e);