diff --git a/Packs/GoogleSheets/Integrations/GoogleSheets/GoogleSheets.py b/Packs/GoogleSheets/Integrations/GoogleSheets/GoogleSheets.py index 52a6a407902a..f84c9fa8ed70 100644 --- a/Packs/GoogleSheets/Integrations/GoogleSheets/GoogleSheets.py +++ b/Packs/GoogleSheets/Integrations/GoogleSheets/GoogleSheets.py @@ -1,3 +1,4 @@ +import ast import demistomock as demisto # noqa: F401 from CommonServerPython import * # noqa: F401 import json @@ -105,15 +106,33 @@ def handle_values_input(values: str) -> list: Returns: (list) A list of lists of the values for this example [[1,2,3],[4,5,6]...] """ - if not values: - raise ValueError('Wrong format of values entered, please check the documentation') - split_by_brackets = re.findall("\[(.*?)\]", values) - res_for_values_req = [] - for element in split_by_brackets: - res_for_values_req.append(element.split(",")) - if not res_for_values_req: - raise ValueError('Wrong format of values entered, please check the documentation') + # Validate that the user has entered valid values + if not values or not re.findall("\[(.*?)\]", values): + raise ValueError( + "Wrong format of values entered, please check the documentation" + ) + + # Converting the values the user entered into an array of arrays + values_as_array = ast.literal_eval(values) + + # Checks whether the given values are a singular empty list, such as "[]". + # if that's the case, it will convert it to [[]] (a list of lists). + if isinstance(values_as_array, list) and len(values_as_array) == 0: + values_as_array = [values_as_array] + + # Checks whether the given values are a single non-empty list, e.g., "[1,2,3]". + # in such a case, it will convert it to [[1,2,3]] (a list of lists). + elif not all(isinstance(item, list) for item in values_as_array): + values_as_array = [values_as_array] + + # Handling all values including the `None` value to be string + res_for_values_req = [] + for element in values_as_array: + if not element: + res_for_values_req.append([""]) + continue + res_for_values_req.append([str(value) for value in element]) return res_for_values_req diff --git a/Packs/GoogleSheets/Integrations/GoogleSheets/GoogleSheets_test.py b/Packs/GoogleSheets/Integrations/GoogleSheets/GoogleSheets_test.py index b270f943ccfa..5d64cf9d8698 100644 --- a/Packs/GoogleSheets/Integrations/GoogleSheets/GoogleSheets_test.py +++ b/Packs/GoogleSheets/Integrations/GoogleSheets/GoogleSheets_test.py @@ -134,9 +134,12 @@ def test_create_list_id_title(): handle_values_input_parametrized = [ ("[1,2,3],[4,5,6]", [['1', '2', '3'], ['4', '5', '6']]), + ("[1,'test, for test',3],[4,5,6]", [['1', 'test, for test', '3'], ['4', '5', '6']]), + ("[1,[2],3],[4,5,6]", [['1', '[2]', '3'], ['4', '5', '6']]), ("[1,2]", [['1', '2']]), ("[1]", [['1']]), - ("[]", [['']]) + ("[]", [['']]), + ("[[1,2,3],[4,5,6]]", [['1', '2', '3'], ['4', '5', '6']]) ] diff --git a/Packs/GoogleSheets/ReleaseNotes/1_0_36.md b/Packs/GoogleSheets/ReleaseNotes/1_0_36.md new file mode 100644 index 000000000000..3b4c89190c7c --- /dev/null +++ b/Packs/GoogleSheets/ReleaseNotes/1_0_36.md @@ -0,0 +1,6 @@ + +#### Integrations + +##### Google Sheets +- Updated the Docker image to: *demisto/googleapi-python3:1.0.0.78508*. +- Fixed an issue where the ***google-sheets-value-append*** command incorrectly appended values to a spreadsheet. diff --git a/Packs/GoogleSheets/pack_metadata.json b/Packs/GoogleSheets/pack_metadata.json index 7bf28c0c2a74..b4b7262fd3c6 100644 --- a/Packs/GoogleSheets/pack_metadata.json +++ b/Packs/GoogleSheets/pack_metadata.json @@ -2,7 +2,7 @@ "name": "Google Sheets", "description": "The Google Sheets API is a RESTful interface that lets you read and modify a spreadsheet's data. The most common uses of this API include the following tasks- create spreadsheets, read and write spreadsheets cells, update spreadsheet formatting", "support": "xsoar", - "currentVersion": "1.0.35", + "currentVersion": "1.0.36", "author": "Cortex XSOAR", "url": "https://www.paloaltonetworks.com/cortex", "email": "",