Skip to content

[Night Shift] Fix +append --json-values multi-row bug#318

Open
Pgarciapg wants to merge 1 commit intogoogleworkspace:mainfrom
Pgarciapg:exec-assistant/2026-03-09
Open

[Night Shift] Fix +append --json-values multi-row bug#318
Pgarciapg wants to merge 1 commit intogoogleworkspace:mainfrom
Pgarciapg:exec-assistant/2026-03-09

Conversation

@Pgarciapg
Copy link

Summary

  • Fixed +append --json-values flattening multi-row input into a single row
  • Changed AppendConfig.values from Vec<String> to Vec<Vec<String>> to preserve the 2D array structure
  • Updated parse_append_args to keep parsed Vec<Vec<String>> directly instead of calling .flatten().collect()
  • Wrapped --values comma-separated path in an outer vec for consistency
  • Fixed build_append_request to pass config.values directly (already 2D)
  • Updated existing tests and added test_parse_append_args_json_multirow

Test plan

  • All 6 sheets tests pass (cargo test helpers::sheets)
  • No existing tests broken
  • Includes changeset

🤖 Generated with Claude Code

Change AppendConfig.values from Vec<String> to Vec<Vec<String>> so that
multi-row JSON input is preserved as a 2D array instead of being
flattened. Update parse_append_args to keep the parsed Vec<Vec<String>>
directly, wrap --values comma path in an outer vec, and fix
build_append_request to pass config.values directly. Add new
test_parse_append_args_json_multirow test.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@changeset-bot
Copy link

changeset-bot bot commented Mar 9, 2026

🦋 Changeset detected

Latest commit: 24d82d5

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 9, 2026
@google-cla
Copy link

google-cla bot commented Mar 9, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@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 resolves a critical bug in the +append --json-values command where multi-row JSON input was incorrectly flattened into a single row, leading to data loss or corruption. The changes involve updating the internal data structure for append values to a 2D array and adjusting the parsing and request building logic to correctly handle and preserve multi-dimensional data, ensuring accurate spreadsheet appends.

Highlights

  • Bug Fix: Fixed +append --json-values flattening multi-row input into a single row.
  • Data Structure Change: Changed AppendConfig.values from Vec<String> to Vec<Vec<String>> to preserve the 2D array structure.
  • Argument Parsing: Updated parse_append_args to keep parsed Vec<Vec<String>> directly instead of calling .flatten().collect() and to wrap --values comma-separated input in an outer vector for consistency.
  • Request Building: Fixed build_append_request to pass config.values directly, as it is now correctly a 2D array.
  • Testing: Updated existing tests to reflect the new data structure and added test_parse_append_args_json_multirow to specifically test multi-row JSON parsing.
Changelog
  • .changeset/fix-append-json-multirow.md
    • Added a changeset file documenting the fix for the multi-row bug.
  • src/helpers/sheets.rs
    • Updated build_append_request to directly use the 2D config.values for the request body.
    • Modified AppendConfig.values from a single Vec<String> to a Vec<Vec<String>> to support 2D data.
    • Adjusted parse_append_args to correctly handle and retain 2D json-values and to wrap --values input in an outer vector.
    • Updated test_build_append_request to reflect the new 2D values structure and to assert the JSON body content.
    • Added test_parse_append_args_json_multirow to verify correct parsing of multi-row JSON input.
Activity
  • No human activity has been recorded on 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 correctly fixes a bug in the +append --json-values command where multi-row inputs were being flattened. The change to AppendConfig.values to use a 2D vector (Vec<Vec<String>>) is appropriate, and the related parsing logic and test cases have been updated accordingly. The addition of a new test case for multi-row JSON input is a good measure to prevent regressions. I have one piece of feedback regarding error handling for invalid JSON input, which currently fails silently.

Comment on lines +280 to +282
serde_json::from_str::<Vec<String>>(json_str)
.map(|row| vec![row])
.unwrap_or_default()
Copy link
Contributor

Choose a reason for hiding this comment

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

high

Using unwrap_or_default() here silently ignores JSON parsing errors. If a user provides malformed JSON to --json-values, the command will proceed with an empty list of values instead of reporting an error. This can be misleading and cause users to believe their data was appended when it was not. The command should fail with a clear error message on invalid input.

A proper fix would involve changing parse_append_args to return a Result<AppendConfig, GwsError> to propagate the error from serde_json. Since that requires changes outside the modified lines, the suggestion below will panic on error to make the failure explicit, which is preferable to silent failure.

Suggested change
serde_json::from_str::<Vec<String>>(json_str)
.map(|row| vec![row])
.unwrap_or_default()
serde_json::from_str::<Vec<String>>(json_str)
.map(|row| vec![row])
.unwrap_or_else(|e| panic!("Invalid --json-values: {}. Failed to parse as a 2D or 1D array of strings.", e))

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