Skip to content

fix(output): write JSON-wrapped base64 attachment payloads with --output#724

Open
jeevan6996 wants to merge 2 commits intogoogleworkspace:mainfrom
jeevan6996:fix/714-output-json-base64-file
Open

fix(output): write JSON-wrapped base64 attachment payloads with --output#724
jeevan6996 wants to merge 2 commits intogoogleworkspace:mainfrom
jeevan6996:fix/714-output-json-base64-file

Conversation

@jeevan6996
Copy link
Copy Markdown

Summary

  • make --output handle JSON responses that contain base64url binary payloads in a data field (for example gmail.users.messages.attachments.get)
  • decode and write bytes to the requested file path instead of silently succeeding without creating a file
  • return a clear validation error when --output is used with JSON responses that do not contain a decodable data payload
  • add regression tests for decoding behavior and output handling, plus a changeset

Fixes #714

Validation

  • could not run local Rust tests in this environment because cargo is not installed (command not found)

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 14, 2026

🦋 Changeset detected

Latest commit: 5750dc8

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 enhances the CLI's handling of JSON responses that contain binary attachments, specifically targeting APIs like Gmail. It ensures that when a user specifies an output file, the CLI correctly identifies, decodes, and persists the binary data rather than ignoring it. The changes also introduce necessary validation to prevent conflicting flag usage and include robust testing to ensure future stability.

Highlights

  • Base64 Decoding Support: Implemented logic to detect and decode base64url-encoded binary payloads found within JSON 'data' fields.
  • File Output Handling: Updated the --output flag to correctly write decoded binary data to the specified file path instead of failing silently.
  • Validation Improvements: Added validation to prevent the use of --output in conjunction with --page-all, and ensured clear error messages for invalid payloads.
  • Regression Testing: Added comprehensive unit and integration tests to verify decoding behavior and file writing operations.
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.

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 enables the --output flag to decode JSON-wrapped base64url payloads and write the binary data to disk. Review feedback identifies a compilation error in the added tests due to an undefined function and suggests that the implementation should fall back to writing raw JSON when no base64 payload is detected to avoid regressions in CLI behavior.

@jeevan6996
Copy link
Copy Markdown
Author

jeevan6996 commented Apr 14, 2026

I intentionally kept the behaviour fail-loud for --output when JSON does not contain a decodable base64url data field, because the issue here is silent success with no file written. Returning a clear validation error makes the failure visible and prevents data-loss-style false positives in automation flows. Happy to adjust to a different fallback if maintainers prefer (for example, explicit opt-in to write raw JSON).

@jeevan6996
Copy link
Copy Markdown
Author

Addressed the scope/compile concern: removed the unrelated Tasks warning tests from this PR so it stays focused on issue #714 output decoding behavior. Pushed in 5750dc8.

@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 enables the --output flag to decode and save JSON-wrapped base64url payloads, such as Gmail attachments, directly to disk. It introduces a new helper function for base64url decoding, adds validation to prevent the use of --output with --page-all for JSON responses, and includes unit tests to verify the decoding and file-writing logic. I have no feedback to provide as there were no review comments.

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.

--output silently succeeds without writing a file when the API returns JSON-wrapped base64 (e.g. gmail.users.messages.attachments.get)

2 participants