Skip to content

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

Open
hoyt-harness wants to merge 1 commit intogoogleworkspace:mainfrom
hoyt-harness:fix/743-calendar-204-misrouting
Open

fix(executor): short-circuit 204 No Content before binary response routing#749
hoyt-harness wants to merge 1 commit intogoogleworkspace:mainfrom
hoyt-harness:fix/743-calendar-204-misrouting

Conversation

@hoyt-harness
Copy link
Copy Markdown

Summary

calendar events delete (and any endpoint whose 204 No Content response happens to carry a non-empty Content-Type header — in this case text/html) was being mis-routed into handle_binary_response(). This caused:

  • An empty download.html file written to cwd as a side-effect
  • A spurious {"bytes":0,"mimeType":"text/html","saved_file":"download.html","status":"success"} printed to stdout instead of clean empty output

Root cause: the dispatch branch at the bottom of execute_method() keys on is_json || content_type.is_empty(). A text/html 204 is neither, so it falls through to the binary path. Other delete endpoints (Gmail labels, drafts, filters; Tasks tasklists; People deleteContact) return a 204 with an empty Content-Type, so they hit the JSON branch and produce clean output.

Fix

Add an early break immediately after the tracing::debug! log when status == 204 No Content. No response body exists to parse or save, so we exit the loop cleanly regardless of what the Content-Type header says.

Also collapses a pre-existing clippy::collapsible_match warning in helpers/script.rs (same one fixed in PRs #744 and #747; it re-appears on branches based off upstream/main until one of those PRs merges).

Test plan

  • gws calendar events delete --params '{"calendarId":"primary","eventId":"<id>","sendUpdates":"none"}' now produces clean empty stdout and no download.html file
  • Other 204 endpoints (gmail labels delete, tasks tasklists delete, etc.) continue producing clean empty output
  • Non-204 binary endpoints (drive files export, drive files get --alt media) are unaffected — their responses have non-empty bodies and are not status 204
  • cargo clippy -- -D warnings passes
  • cargo test passes (excluding the two pre-existing auth::tests::test_get_quota_project_* failures that are environment-specific ADC file reads unrelated to this change)

Fixes #743 (sub-issue 4d)

🤖 Generated with Claude Code

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 22, 2026

🦋 Changeset detected

Latest commit: 4e27bdc

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

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses an issue where specific API endpoints returning a 204 No Content status were being incorrectly processed as binary responses due to the presence of a non-empty Content-Type header. By introducing an early exit for 204 responses, the CLI now correctly handles these cases without creating spurious files or output. Additionally, a minor code cleanup was performed to satisfy linting requirements.

Highlights

  • Fix 204 No Content Routing: Added an early break in the executor when a 204 No Content status is received, preventing incorrect routing to the binary response handler for endpoints that return a non-empty Content-Type header.
  • Code Cleanup: Refactored match arms in the script helper to resolve a clippy::collapsible_match warning.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Generative AI Prohibited Use Policy, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@googleworkspace-bot googleworkspace-bot added area: http area: core Core CLI parsing, commands, error handling, utilities labels Apr 22, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request fixes a bug where 204 No Content responses were incorrectly routed to binary download paths, which caused empty files to be written to the disk. The fix introduces an early break in the executor when a 204 status is detected. Feedback was provided regarding an unrelated refactor in script.rs, which is considered out of scope and redundant as it is being addressed in other pull requests.

Comment thread crates/google-workspace-cli/src/helpers/script.rs Outdated
…uting

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 googleworkspace#743 (sub-issue 4d)
@hoyt-harness hoyt-harness force-pushed the fix/743-calendar-204-misrouting branch from 6bf7d5e to 4e27bdc Compare April 22, 2026 21:51
@hoyt-harness
Copy link
Copy Markdown
Author

Good catch — the helpers/script.rs refactor has been dropped from this PR. The commit now only touches executor.rs (the 204 short-circuit) and the changeset file.

@googleworkspace-bot googleworkspace-bot removed the area: core Core CLI parsing, commands, error handling, utilities label Apr 22, 2026
@googleworkspace-bot
Copy link
Copy Markdown
Collaborator

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request fixes an issue where 204 No Content responses were incorrectly routed to the binary download path if they contained a Content-Type header. An early break was added in the executor to handle 204 status codes correctly. I have no feedback to provide.

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

Projects

None yet

2 participants