The function Data Table Utils: Get Row fails when one of the cells that is searched before the value is empty. This is because bracket notation is being used to access the value of the cell. If the cell does not have a value (it's empty) then the value key doesn't exist in the cell dictionary and the code raises a KeyError exception.
Describe How to Reproduce
If I have the following data table:
and I am using the Data Table Utils: Get Row function to search for a row that has a value of 'testing' in the 'Username' column, the function will throw a KeyError with the following stack trace:
Traceback (most recent call last):
File "/home/liam/Documents/resilient/resilient-community-apps/fn_datatable_utils/fn_datatable_utils/components/dt_utils_get_row.py", line 72, in _dt_utils_get_row_function
row = datatable.get_row(payload.inputs["dt_utils_row_id"], payload.inputs["dt_utils_search_column"], payload.inputs["dt_utils_search_value"])
File "/home/liam/Documents/resilient/resilient-community-apps/fn_datatable_utils/fn_datatable_utils/util/helper.py", line 42, in get_row
if cells[search_column]["value"] == search_value:
KeyError: 'value'
This happens because line 42 in fn_datatable_utils/fn_datatable_utils/util/helper.py uses bracket notation if cells[search_column]["value"] == search_value:. The row object looks like this:
Description
The function
Data Table Utils: Get Row
fails when one of the cells that is searched before the value is empty. This is because bracket notation is being used to access thevalue
of the cell. If the cell does not have a value (it's empty) then thevalue
key doesn't exist in thecell
dictionary and the code raises a KeyError exception.Describe How to Reproduce
If I have the following data table:
and I am using the
Data Table Utils: Get Row
function to search for a row that has a value of 'testing' in the 'Username' column, the function will throw aKeyError
with the following stack trace:This happens because line 42 in
fn_datatable_utils/fn_datatable_utils/util/helper.py
uses bracket notationif cells[search_column]["value"] == search_value:
. The row object looks like this:and
cells[search_column]
looks like this:Since
cells[search_column]
does not have a key 'value' theKeyError
is thrown.