fix(executor): short-circuit 204 No Content before binary response routing#749
fix(executor): short-circuit 204 No Content before binary response routing#749hoyt-harness wants to merge 1 commit intogoogleworkspace:mainfrom
Conversation
🦋 Changeset detectedLatest commit: 4e27bdc The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
Summary of ChangesHello, 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
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
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.
…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)
6bf7d5e to
4e27bdc
Compare
|
Good catch — the |
|
/gemini review |
There was a problem hiding this comment.
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.
Summary
calendar events delete(and any endpoint whose 204 No Content response happens to carry a non-emptyContent-Typeheader — in this casetext/html) was being mis-routed intohandle_binary_response(). This caused:download.htmlfile written to cwd as a side-effect{"bytes":0,"mimeType":"text/html","saved_file":"download.html","status":"success"}printed to stdout instead of clean empty outputRoot cause: the dispatch branch at the bottom of
execute_method()keys onis_json || content_type.is_empty(). Atext/html204 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 emptyContent-Type, so they hit the JSON branch and produce clean output.Fix
Add an early
breakimmediately after thetracing::debug!log whenstatus == 204 No Content. No response body exists to parse or save, so we exit the loop cleanly regardless of what theContent-Typeheader says.Also collapses a pre-existing
clippy::collapsible_matchwarning inhelpers/script.rs(same one fixed in PRs #744 and #747; it re-appears on branches based offupstream/mainuntil one of those PRs merges).Test plan
gws calendar events delete --params '{"calendarId":"primary","eventId":"<id>","sendUpdates":"none"}'now produces clean empty stdout and nodownload.htmlfile--alt media) are unaffected — their responses have non-empty bodies and are not status 204cargo clippy -- -D warningspassescargo testpasses (excluding the two pre-existingauth::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