Skip to content

+append --json-values flattens multi-row arrays into a single row #311

@ncoop57

Description

@ncoop57

Description

When using +append --json-values with a multi-row JSON array, all values are appended as a single row instead of separate rows.

Steps to Reproduce

# Append 2 rows via --json-values
gws sheets +append --spreadsheet <ID> --json-values '[["Alice","100"],["Bob","200"]]'

Expected: 2 rows appended

A B
Alice 100
Bob 200

Actual: 1 row appended with all values concatenated across columns

A B C D
Alice 100 Bob 200

Possible Cause

This may be related to parse_append_args in src/helpers/sheets.rs — the --json-values branch parses the input as Vec<Vec<String>> but then calls .flatten().collect(), collapsing it into a single flat Vec<String>. Is this intentional, perhaps to support a specific use case? If not, it looks like AppendConfig.values would need to become Vec<Vec<String>> to preserve the row structure through to build_append_request.

Workaround

Using the raw API works correctly for multi-row appends:

gws sheets spreadsheets values append \
  --params '{"spreadsheetId": "<ID>", "range": "Sheet1!A1", "valueInputOption": "USER_ENTERED"}' \
  --json '{"values": [["Alice","100"],["Bob","200"]]}'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions