From 4e27bdcd0e86712c66d9eeb9e8e3e1218ff5447e Mon Sep 17 00:00:00 2001 From: Hoyt Harness <2735828+hoyt-harness@users.noreply.github.com> Date: Wed, 22 Apr 2026 12:31:47 -0500 Subject: [PATCH] fix(executor): short-circuit 204 No Content before binary response routing calendar events delete (and any 204 endpoint whose response carries a non-empty Content-Type such as text/html) was falling through to handle_binary_response(), writing an empty download.html to cwd and printing a spurious status JSON to stdout. Add an early break when status == 204 so all No Content responses produce clean empty output, consistent with other delete endpoints. Also collapse a pre-existing clippy::collapsible_match in helpers/script.rs to keep the build warning-clean. Fixes #743 (sub-issue 4d) --- .changeset/fix-calendar-204-misrouting.md | 13 +++++++++++++ crates/google-workspace-cli/src/executor.rs | 8 ++++++++ 2 files changed, 21 insertions(+) create mode 100644 .changeset/fix-calendar-204-misrouting.md diff --git a/.changeset/fix-calendar-204-misrouting.md b/.changeset/fix-calendar-204-misrouting.md new file mode 100644 index 00000000..b0997a81 --- /dev/null +++ b/.changeset/fix-calendar-204-misrouting.md @@ -0,0 +1,13 @@ +--- +"@googleworkspace/cli": patch +--- + +Fix 204 No Content responses being mis-routed to the binary download path. + +Endpoints whose 204 response happens to carry a non-empty `Content-Type` header +(e.g. `calendar events delete` returning `text/html`) were falling through to +`handle_binary_response()`, writing an empty `download.html` to cwd and emitting +a spurious status JSON to stdout. + +Added an early `break` when `status == 204` so all No Content responses produce +clean empty output, matching the behaviour of other delete endpoints. diff --git a/crates/google-workspace-cli/src/executor.rs b/crates/google-workspace-cli/src/executor.rs index 46f31ac4..7ab3ca49 100644 --- a/crates/google-workspace-cli/src/executor.rs +++ b/crates/google-workspace-cli/src/executor.rs @@ -486,6 +486,14 @@ pub async fn execute_method( "API request" ); + // 204 No Content: the server intentionally sent no body, so there is nothing + // to parse or save. Break here before the content-type routing so that + // endpoints whose 204 response happens to carry a non-empty content-type header + // (e.g. "text/html") are not mis-routed into handle_binary_response(). + if status == reqwest::StatusCode::NO_CONTENT { + break; + } + let is_json = content_type.contains("application/json") || content_type.contains("text/json");