Skip to content

Commit

Permalink
bug fix: prevent thrown exception when indexed property is missing
Browse files Browse the repository at this point in the history
This often happens when updating datasets because the properties to index
will include a property which hasn't been uploaded yet.
  • Loading branch information
pgm committed Jul 23, 2024
1 parent c7f9496 commit b6db3ed
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions breadbox/breadbox/crud/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,16 +376,22 @@ def create_index_records_for_row(
db.query(Dataset).filter(Dataset.id == referenced_dataset_id).one()
)

if (
row.property_metadata[property].annotation_type
== AnnotationType.list_strings
):
values = cast_tabular_cell_value_type(
row.property_metadata[property].value,
row.property_metadata[property].annotation_type,
)
if property not in row.property_metadata:
# if the property doesn't exist, just skip it instead of throwing an exception
# This often happens when updating datasets because the properties to index
# will include a property which hasn't been uploaded yet.
continue
else:
values = [row.property_metadata[property].value]
if (
row.property_metadata[property].annotation_type
== AnnotationType.list_strings
):
values = cast_tabular_cell_value_type(
row.property_metadata[property].value,
row.property_metadata[property].annotation_type,
)
else:
values = [row.property_metadata[property].value]

assert isinstance(values, list)
parent_dimension_id = row.property_metadata[property].dimension_id
Expand Down

0 comments on commit b6db3ed

Please sign in to comment.