Skip to content

feat: add --dry-run support to events helper commands#457

Open
joeVenner wants to merge 1 commit intogoogleworkspace:mainfrom
joeVenner:fix/dry-run-review-updates
Open

feat: add --dry-run support to events helper commands#457
joeVenner wants to merge 1 commit intogoogleworkspace:mainfrom
joeVenner:fix/dry-run-review-updates

Conversation

@joeVenner
Copy link

@joeVenner joeVenner commented Mar 13, 2026

Add dry-run mode to gws events +renew and gws events +subscribe commands. When --dry-run is specified, the commands print what actions would be taken without making any API calls. This allows agents to simulate requests and learn without reaching the server.

Description

Please include a summary of the change and which issue is fixed. If adding a new feature or command, please include the output of running it with --dry-run to prove the JSON request body matches the Discovery Document schema.

Dry Run Output:

// Paste --dry-run output here if applicable

Checklist:

  • My code follows the AGENTS.md guidelines (no generated google-* crates).
  • I have run cargo fmt --all to format the code perfectly.
  • I have run cargo clippy -- -D warnings and resolved all warnings.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have provided a Changeset file (e.g. via pnpx changeset) to document my changes.

@changeset-bot
Copy link

changeset-bot bot commented Mar 13, 2026

🦋 Changeset detected

Latest commit: 15be912

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

@googleworkspace-bot googleworkspace-bot added the area: core Core CLI parsing, commands, error handling, utilities label Mar 13, 2026
@gemini-code-assist
Copy link
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 introduces a --dry-run mode for the gws events +renew and gws events +subscribe helper commands. This enhancement allows users to preview the actions these commands would take, such as reactivating subscriptions or creating new ones, without actually interacting with the Google Workspace Events API or Pub/Sub. This provides a safe way to understand and verify command behavior before executing potentially impactful operations.

Highlights

  • Dry Run Support: Added --dry-run functionality to the gws events +renew and gws events +subscribe commands, allowing users to simulate API calls without making actual changes.
  • Renew Command Enhancement: The renew command now checks for the --dry-run flag, preventing actual subscription reactivation API calls and instead printing the intended actions in JSON format.
  • Subscribe Command Enhancement: The subscribe command now respects the --dry-run flag, simulating the creation of Pub/Sub topics, subscriptions, and Workspace Events subscriptions without performing real API operations.
Changelog
  • @googleworkspace/cli
    • feat(helpers): add --dry-run support to events helper commands
Activity
  • No specific activity (comments, reviews, progress updates) has been recorded for this pull request yet.
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.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

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
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 adds --dry-run support to the events +renew and events +subscribe helper commands, which is a great feature for usability and testing. The implementation in subscribe.rs is well-structured by handling the dry-run case and exiting early. However, the implementation in renew.rs has introduced significant code complexity and duplication. I've provided a suggestion to refactor it for better maintainability, following the cleaner pattern used in subscribe.rs. Additionally, there's a small piece of duplicated code in subscribe.rs that can be removed. Addressing these points will make the code cleaner and easier to maintain.

@joeVenner joeVenner force-pushed the fix/dry-run-review-updates branch from e1e9983 to 38fbb1e Compare March 13, 2026 02:56
@googleworkspace-bot
Copy link
Collaborator

/gemini review

Copy link
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 adds --dry-run support to the events +renew and events +subscribe helper commands. The implementation for +renew looks good, but I found a critical issue in +subscribe where the dry-run mode is not honored when an existing subscription is used, leading to real API calls being made. Additionally, I've pointed out a couple of places where error handling could be improved by avoiding unwrap_or_default() to prevent silently failing on serialization errors.

@joeVenner joeVenner force-pushed the fix/dry-run-review-updates branch from 38fbb1e to 92b1e6a Compare March 13, 2026 03:02
@joeVenner
Copy link
Author

Fixed Issues:

  1. Critical: Added dry-run check for existing subscription (--subscription flag) in subscribe.rs - now properly exits early with dry-run output

  2. High: Changed unwrap_or_default() to unwrap() for json serialization to prevent hiding errors

@googleworkspace-bot
Copy link
Collaborator

/gemini review

Copy link
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 introduces a --dry-run feature to the events +renew and events +subscribe helper commands, which is a great addition for usability and testing. The implementation correctly adds an early-exit path for dry runs.

However, I've identified a critical issue across the changes: several calls to serde_json::to_string_pretty are followed by .unwrap(). This can cause the CLI to panic if serialization fails for any reason. In some places, this even replaces the safer unwrap_or_default() from the previous code. My review comments include suggestions to handle these Results gracefully and prevent potential crashes.

@joeVenner joeVenner force-pushed the fix/dry-run-review-updates branch from 92b1e6a to c7b347e Compare March 13, 2026 03:07
@joeVenner
Copy link
Author

Fixed! Reverted .unwrap() back to .unwrap_or_default() in both files to keep the safer error handling that won't cause CLI panics.

  • ✅ Fixed dry-run for existing subscription flag
  • ✅ Using unwrap_or_default() for safer error handling

@googleworkspace-bot
Copy link
Collaborator

/gemini review

Copy link
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 introduces a --dry-run mode for the events +renew and events +subscribe helper commands, which is a great feature for usability and testing. The implementation correctly separates the dry-run logic from the actual execution. However, there is a critical issue in how JSON serialization errors are handled. The use of unwrap_or_default() can lead to silent failures where the command exits successfully but produces no output, which can be problematic for scripting and automation. I've added comments with suggestions to properly propagate these errors.

@joeVenner joeVenner force-pushed the fix/dry-run-review-updates branch from c7b347e to f812893 Compare March 13, 2026 08:56
@googleworkspace-bot
Copy link
Collaborator

/gemini review

Copy link
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 introduces a valuable --dry-run mode for the events +renew and events +subscribe commands, enhancing usability by allowing users to preview actions without making API calls. The implementation is largely well-executed. However, I've identified a performance issue in the +subscribe command where an authentication token is fetched eagerly, even in scenarios where it's not used. My review includes a detailed comment on this issue with a recommendation for improvement.

@joeVenner
Copy link
Author

Fixed! Reverted .unwrap() back to .unwrap_or_default() in both files to keep the safer error handling that won't cause CLI panics.

All code review fixes have been applied and pushed to fix/dry-run-review-updates:

  • ✅ Fixed dry-run for existing subscription flag
  • ✅ Using unwrap_or_default() for safer error handling

@joeVenner joeVenner force-pushed the fix/dry-run-review-updates branch from f812893 to 7b40990 Compare March 13, 2026 09:03
@googleworkspace-bot
Copy link
Collaborator

/gemini review

Copy link
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 introduces a --dry-run mode for the events +renew and events +subscribe helper commands, which is a valuable feature for allowing users to simulate commands without making live API calls. The implementation correctly isolates the dry-run logic and prevents side effects like API calls and directory creation. I've identified one high-severity issue in subscribe.rs where an input parameter is not validated in the dry-run path, potentially leading to misleading output. Addressing this will make the dry-run simulation more reliable.

Add dry-run mode to gws events +renew and gws events +subscribe commands.
When --dry-run is specified, the commands print what actions would be
taken without making any API calls. This allows agents to simulate
requests and learn without reaching the server.
@joeVenner joeVenner force-pushed the fix/dry-run-review-updates branch from 7b40990 to 15be912 Compare March 13, 2026 09:54
@googleworkspace-bot
Copy link
Collaborator

/gemini review

@joeVenner
Copy link
Author

Code Review Fixes Applied

  • Token fetching optimization: The Pub/Sub token is now only fetched when creating a new subscription, not when using an existing --subscription

  • Input validation in dry-run path: The --target parameter is now validated using validate_resource_name() before being used in both dry-run and actual execution paths, ensuring dry-run accurately simulates what would happen in a real run

Copy link
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 introduces a --dry-run mode for the gws events +renew and gws events +subscribe commands. The implementation correctly adds logic to simulate the commands' actions and print the expected outcomes without making any actual API calls or filesystem changes. The changes are well-structured, exiting early in the command handlers for dry runs. Additionally, the PR improves error handling by replacing unwrap_or_default() with proper error propagation when serializing JSON, which enhances the robustness of the CLI. The code quality is high and I did not find any issues of high or critical severity.

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

Labels

area: core Core CLI parsing, commands, error handling, utilities

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants