[Night Shift] Fix +append --json-values multi-row bug#318
[Night Shift] Fix +append --json-values multi-row bug#318Pgarciapg wants to merge 1 commit intogoogleworkspace:mainfrom
Conversation
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 detectedLatest commit: 24d82d5 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 resolves a critical bug in the Highlights
Changelog
Activity
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 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.
| serde_json::from_str::<Vec<String>>(json_str) | ||
| .map(|row| vec![row]) | ||
| .unwrap_or_default() |
There was a problem hiding this comment.
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.
| 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)) |
Summary
+append --json-valuesflattening multi-row input into a single rowAppendConfig.valuesfromVec<String>toVec<Vec<String>>to preserve the 2D array structureparse_append_argsto keep parsedVec<Vec<String>>directly instead of calling.flatten().collect()--valuescomma-separated path in an outer vec for consistencybuild_append_requestto passconfig.valuesdirectly (already 2D)test_parse_append_args_json_multirowTest plan
cargo test helpers::sheets)🤖 Generated with Claude Code