Skip to content

Commit

Permalink
Trust data in db_state.json (#40)
Browse files Browse the repository at this point in the history
Remove exception due to s3 file field not matching the db_state.json
file field.

---------

Co-authored-by: Mark <[email protected]>
  • Loading branch information
THOR300 and Mark authored Apr 13, 2023
1 parent 1af1b05 commit 9a16c0a
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions src/navigator_data_ingest/base/updated_document_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,24 +261,24 @@ def update_file_field(
document = json.loads(document_path.read_text())

try:
assert str(document[pipeline_field]) == str(existing_value)
except AssertionError:
_LOGGER.error(
"Field value mismatch - expected value not found in s3 object.",
extra={
"props": {
"document_path": str(document_path),
"field": field,
"pipeline_field": pipeline_field,
"value": new_value,
"existing_value": existing_value,
"document": document,
}
},
)
return "FieldMismatchError: Expected value not found in s3 object."
if not str(document[pipeline_field]) == str(existing_value):
_LOGGER.info(
"Existing value doesn't match.",
extra={
"props": {
"document_path": str(document_path),
"field": field,
"pipeline_field": pipeline_field,
"value": new_value,
"existing_value": existing_value,
"document": document,
}
},
)

document[pipeline_field] = new_value
except KeyError:
_LOGGER.error(
_LOGGER.exception(
"Field not found in s3 object.",
extra={
"props": {
Expand All @@ -292,7 +292,7 @@ def update_file_field(
},
)
return traceback.format_exc()
document[pipeline_field] = new_value

document_path.write_text(json.dumps(document))
return None
else:
Expand Down

0 comments on commit 9a16c0a

Please sign in to comment.