Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .changeset/fix-calendar-204-misrouting.md
Original file line number Diff line number Diff line change
@@ -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.
8 changes: 8 additions & 0 deletions crates/google-workspace-cli/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
Loading