fix(sheets): preserve multi-row structure in +append --json-values#410
fix(sheets): preserve multi-row structure in +append --json-values#410anshul-garg27 wants to merge 3 commits intogoogleworkspace:mainfrom
Conversation
Previously, `parse_append_args` called `.flatten()` on the parsed `Vec<Vec<String>>`, collapsing all rows into a single flat vector. Combined with `build_append_request` wrapping the flat vec in another array, this meant `[["Alice","100"],["Bob","200"]]` produced one row with four columns instead of two rows with two columns each. Change `AppendConfig.values` from `Vec<String>` to `Vec<Vec<String>>` so row boundaries are preserved end-to-end. Single-row inputs via `--values` and flat JSON arrays are wrapped in a single-element outer vec for consistency. Closes googleworkspace#311
🦋 Changeset detectedLatest commit: a881528 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 |
|
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. |
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 a critical bug in the Highlights
Changelog
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. 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
|
There was a problem hiding this comment.
Code Review
This pull request fixes a bug in the +append --json-values command where multi-row arrays were incorrectly flattened into a single row before being sent to the Google Sheets API. The AppendConfig struct's values field has been updated from Vec<String> to Vec<Vec<String>> to correctly represent multiple rows. The parse_append_args function was refactored to properly parse both single and multi-row JSON inputs, as well as single-row comma-separated inputs, into this new Vec<Vec<String>> structure. Consequently, the build_append_request function now directly uses this multi-row structure for the API request body, ensuring the preservation of row integrity. New test cases were added to validate the correct parsing and API request body construction for various single and multi-row scenarios.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request correctly fixes an issue where multi-row JSON arrays were being flattened into a single row when using sheets +append --json-values. The change to use Vec<Vec<String>> throughout the call chain and the updated parsing logic are well-implemented. The new tests provide good coverage for the fix. I have one suggestion to improve error handling for malformed JSON input to provide a better user experience.
Address review feedback: print a warning to stderr when --json-values cannot be parsed as a JSON array, rather than silently falling back to an empty value set.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request fixes a bug where the +append --json-values command incorrectly flattened multi-row arrays into a single row when sending data to the Google Sheets API. The AppendConfig struct's values field was updated from Vec<String> to Vec<Vec<String>> to properly represent multiple rows. The parse_append_args function was refactored to correctly parse both single and multi-row JSON inputs for --json-values and to ensure --values also produces a Vec<Vec<String>>. Additionally, the build_append_request function was adjusted to directly use this nested vector for the API request body, and new tests were added to validate the correct handling of single and multi-row data parsing and request construction.
Summary
+append --json-valuesflattening multi-row arrays into a single rowAppendConfig.valuesfromVec<String>toVec<Vec<String>>to preserve row boundaries--valuesand flat JSON arrays) are wrapped in a single-element outer vec for consistencyRoot cause
parse_append_argscalled.flatten()on the parsedVec<Vec<String>>, collapsing all rows into a single flat vector. Combined withbuild_append_requestwrapping that flat vec in another array ("values": [config.values]), the Sheets API always received exactly one row regardless of input shape.Before:
[["Alice","100"],["Bob","200"]]→ 1 row:Alice | 100 | Bob | 200After:
[["Alice","100"],["Bob","200"]]→ 2 rows:Alice | 100andBob | 200Test plan
--json-valueswith multi-row array preserves row structure--json-valueswith single flat array wraps as one row--valueswraps comma-separated values as one rowbuild_append_requestproduces correct multi-row JSON bodyVec<Vec<String>>typeCloses #311