Skip to content

fix(sheets): require values for append helper#787

Open
rohan-patnaik wants to merge 3 commits intogoogleworkspace:mainfrom
rohan-patnaik:fix/sheets-append-require-values
Open

fix(sheets): require values for append helper#787
rohan-patnaik wants to merge 3 commits intogoogleworkspace:mainfrom
rohan-patnaik:fix/sheets-append-require-values

Conversation

@rohan-patnaik
Copy link
Copy Markdown

@rohan-patnaik rohan-patnaik commented May 10, 2026

Description

gws sheets +append should only run when there is row data to append. Previously, the helper accepted a command with only --spreadsheet, which built an empty append request.

This PR makes +append require either --values or --json-values during argument parsing, so users get a clear CLI error before any API request is prepared.

Dry Run Output:

// Not applicable: this validates required input before request creation.

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. See testing note below.
  • 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.

Testing

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 10, 2026

🦋 Changeset detected

Latest commit: 33c3c34

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 improves the reliability of the gws sheets +append command by enforcing the presence of row data at the CLI level. By requiring users to provide either --values or --json-values, the application avoids unnecessary API calls and provides immediate feedback when input is incomplete.

Highlights

  • Input Validation: Updated the +append command to require either --values or --json-values arguments, preventing the creation of empty append requests.
  • Testing: Added a new unit test to verify that the CLI correctly returns an error when required data arguments are missing.
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 the 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 counterproductive. 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 the area: core Core CLI parsing, commands, error handling, utilities label May 10, 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 ensures that row data is provided when using the gws sheets +append command by making the --values and --json-values arguments required unless the other is present. It also includes a unit test to verify this behavior. The review feedback recommends explicitly marking these arguments as conflicting to prevent ambiguity if both are supplied simultaneously.

Comment on lines 43 to 55
Arg::new("values")
.long("values")
.help("Comma-separated values (simple strings)")
.value_name("VALUES"),
.value_name("VALUES")
.required_unless_present("json-values"),
)
.arg(
Arg::new("json-values")
.long("json-values")
.help("JSON array of rows, e.g. '[[\"a\",\"b\"],[\"c\",\"d\"]]'")
.value_name("JSON"),
.value_name("JSON")
.required_unless_present("values"),
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The --values and --json-values arguments are mutually exclusive ways to provide row data. Currently, they are marked as required_unless_present, which ensures at least one is provided, but it allows both to be present simultaneously. If both are provided, the parsing logic in parse_append_args silently prioritizes --json-values and ignores --values, which is ambiguous and can lead to unexpected behavior or data loss. Marking them as conflicting ensures the user provides exactly one valid input method.

                    Arg::new("values")
                        .long("values")
                        .help("Comma-separated values (simple strings)")
                        .value_name("VALUES")
                        .required_unless_present("json-values")
                        .conflicts_with("json-values"),
                )
                .arg(
                    Arg::new("json-values")
                        .long("json-values")
                        .help("JSON array of rows, e.g. '[(\"a\",\"b\"], [\"c\",\"d\"]]'")
                        .value_name("JSON")
                        .required_unless_present("values")
                        .conflicts_with("values"),
                )

@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 updates the gws sheets +append command to require that either the --values or --json-values argument is provided, while also ensuring they are mutually exclusive. New unit tests were added to verify these constraints. The review feedback suggests improving the test robustness by asserting the specific error kind when required arguments are missing, rather than just checking for the presence of any error.

Comment on lines +540 to +543
assert!(
result.is_err(),
"+append should require --values or --json-values"
);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

This test should verify the specific error kind (e.g., ErrorKind::MissingRequiredArgument) to ensure it fails for the expected reason. Without this check, the test could pass if the command fails for other reasons, such as a typo in the subcommand name or a missing required global argument. This also maintains consistency with the test_append_rejects_values_and_json_values_together test below.

Suggested change
assert!(
result.is_err(),
"+append should require --values or --json-values"
);
assert_eq!(
result.unwrap_err().kind(),
clap::error::ErrorKind::MissingRequiredArgument
);

@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 updates the gws sheets +append command to require either the --values or --json-values argument, while ensuring they are mutually exclusive. It also includes a changeset and unit tests to verify these new argument constraints. I have no feedback to provide.

@rohan-patnaik
Copy link
Copy Markdown
Author

Gemini feedback has been addressed in the follow-up commits:

  • 083d5a6 makes --values and --json-values mutually exclusive and adds regression coverage.
  • 33c3c34 tightens the missing-values test to assert the exact MissingRequiredArgument error.

All local validation passed with cargo fmt --all --check, cargo test -q test_append, and cargo test -q.

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