Skip to content

Google Sheets Get All cannot read raw rows when headers are blank or duplicated #986

Description

@notdodo-prima

Describe the bug
The Google Sheets Get All action always calls worksheet.get_all_records(). That requires a unique header row in gspread, so the action fails on worksheets with duplicate or blank headers even when the caller only needs raw rows.

Confirmed in current main at 2a6aa9d40e3ba5ba17787691018069d6a1498cd3:

try:
sheet = GoogleSheetFactory(credentials_json).create_spreadsheet(sheet_id)
if worksheet_name:
worksheet = sheet.worksheet(worksheet_name)
else:
worksheet = sheet.sheet1
list_of_dicts = worksheet.get_all_records()
siemplify.result.add_result_json(list_of_dicts)
except Exception as err:
status = EXECUTION_STATE_FAILED
message = str(err)
else:
status = EXECUTION_STATE_COMPLETED
message = "All rows were fetched successfully"
siemplify.end(message, status is EXECUTION_STATE_COMPLETED, status)

The action metadata exposes only Sheet Id and Worksheet Name; there is no raw row mode or expected_headers parameter:

parameters:
- default_value: <Sheet-Id>
description: 'The sheet id can be found in the sheet url.
https://docs.google.com/spreadsheets/d/{YourSpreadSheetId}/edit#gid=0'
is_mandatory: true
name: Sheet Id
type: string
- default_value: <Sheet-Name>
description: 'The worksheet name is the Sheet tab name. The default Sheet name
is "Sheet1". Note: it is case sensitive. '
is_mandatory: false
name: Worksheet Name
type: string
script_result_name: ScriptResult

To Reproduce
Steps to reproduce the behavior:

  1. Use a worksheet that has duplicate or blank header cells.
  2. Run Google Sheets - Get All.
  3. Set Sheet Id and Worksheet Name.
  4. Observe that the action fails with a gspread header error.

Observed error:

the header row in the worksheet is not unique, try passing 'expected_headers' to get_all_records

Expected behavior
The action should provide a way to read raw rows without requiring unique headers, for example by using worksheet.get_all_values() in a raw mode, or it should expose an expected_headers option for get_all_records().

Additional context
The current behavior makes Get All unusable for tracking sheets that are not modeled as unique-header records.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions