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");