Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix(automation): surface webhook body serialization errors

Richie McIlroy791654c0a730
diff --git a/apps/cli/src/automation.rs b/apps/cli/src/automation.rs
index 73df2cab1..8b3572d1c 100644
--- a/apps/cli/src/automation.rs
+++ b/apps/cli/src/automation.rs
@@ -297,17 +297,17 @@ impl AutomationHost for CliAutomationHost {
let method = method
.parse::<reqwest::Method>()
.map_err(|e| format!("Invalid HTTP method: {e}"))?;
- let body = body_template
- .map(|tmpl| apply_body_template(tmpl, ctx))
- .unwrap_or_else(|| {
- serde_json::to_string(&serde_json::json!({
- "project_path": ctx.project_path,
- "image_path": ctx.image_path,
- "output_path": ctx.output_path,
- "share_link": ctx.share_link,
- }))
- .unwrap_or_default()
- });
+ let body = if let Some(tmpl) = body_template {
+ apply_body_template(tmpl, ctx)
+ } else {
+ serde_json::to_string(&serde_json::json!({
+ "project_path": ctx.project_path,
+ "image_path": ctx.image_path,
+ "output_path": ctx.output_path,
+ "share_link": ctx.share_link,
+ }))
+ .map_err(|e| format!("Failed to serialize webhook body: {e}"))?
+ };
let mut req = client.request(method, url).body(body);
for (k, v) in headers {
diff --git a/apps/desktop/src-tauri/src/automation.rs b/apps/desktop/src-tauri/src/automation.rs
index 86465539f..c669255f4 100644
--- a/apps/desktop/src-tauri/src/automation.rs
+++ b/apps/desktop/src-tauri/src/automation.rs
@@ -360,17 +360,17 @@ impl AutomationHost for DesktopAutomationHost {
.parse::<reqwest::Method>()
.map_err(|e| format!("Invalid HTTP method: {e}"))?;
- let body = body_template
- .map(|tmpl| apply_body_template(tmpl, ctx))
- .unwrap_or_else(|| {
- serde_json::to_string(&serde_json::json!({
- "project_path": ctx.project_path,
- "image_path": ctx.image_path,
- "output_path": ctx.output_path,
- "share_link": ctx.share_link,
- }))
- .unwrap_or_default()
- });
+ let body = if let Some(tmpl) = body_template {
+ apply_body_template(tmpl, ctx)
+ } else {
+ serde_json::to_string(&serde_json::json!({
+ "project_path": ctx.project_path,
+ "image_path": ctx.image_path,
+ "output_path": ctx.output_path,
+ "share_link": ctx.share_link,
+ }))
+ .map_err(|e| format!("Failed to serialize webhook body: {e}"))?
+ };
let mut req = client.request(method, url).body(body);
for (k, v) in headers {