Skip to content

fix(executor): short-circuit 204 No Content before binary response routing - #906

Open
TheSecMaven wants to merge 1 commit into
googleworkspace:mainfrom
TheSecMaven:fix/204-no-content-misrouting
Open

fix(executor): short-circuit 204 No Content before binary response routing#906
TheSecMaven wants to merge 1 commit into
googleworkspace:mainfrom
TheSecMaven:fix/204-no-content-misrouting

Conversation

@TheSecMaven

Copy link
Copy Markdown

Problem

calendar.events.delete and drive.files.delete both return an HTTP 204 No Content
response, but the response still carries a non-empty Content-Type header
(text/html). The executor's JSON-vs-binary routing decision was made purely from
that header, with no earlier check on status code, so a 204 with a text/html
Content-Type fell through into the binary-file handler.

Result: running a plain delete with no --output flag at all —

files delete --params '{"fileId":"FAKE_FILE_ID_1","supportsAllDrives":true}'

— silently creates a zero-byte download.html in the caller's current working
directory, and prints a "status": "success", "saved_file": "download.html" JSON
blob that has nothing to do with what the command actually did.

Related: #743, and the same root cause as the earlier #749 (auto-closed by the stale
bot before review — this PR reimplements the same fix with test coverage).

Fix

Added classify_response_body(status, content_type) -> ResponseBodyKind and made it
the single source of truth for how a response body gets handled. A 204 NO_CONTENT
is now always classified as NoContent regardless of Content-Type, so nothing is
read from or written for it — matching the behavior of every other delete-style
endpoint that returns a genuinely empty body.

Tests

Six new unit tests on classify_response_body cover the exact failure combination
(204 + text/html), 204 with an empty or even application/json Content-Type, and
the unaffected 200-JSON / 200-binary cases. Full crate suite: cargo test -p google-workspace-cli — 707 passed, 0 failed. cargo clippy --all-targets shows no
new warnings from this change.

On the S3 idea

Unrelated to this bug — see the sibling PR for the large-binary-download issue,
where that question actually applies.

…uting

A 204 No Content response that still carries a non-empty Content-Type
header (text/html on calendar.events.delete and drive.files.delete)
was being routed to the binary-file handler purely on that header,
which wrote a stray zero-byte download.html into the caller's cwd and
printed a spurious success status for commands with no --output flag
and nothing to do with downloading.

Introduce classify_response_body(status, content_type) so a 204 is
always treated as having no body to read or write, independent of
whatever Content-Type the endpoint happens to attach to it.
@changeset-bot

changeset-bot Bot commented Aug 23, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 3ed0337

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@googleworkspace/cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@google-cla

google-cla Bot commented Aug 23, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants