Skip to content

Commit 8eb1942

Browse files
committed
fix upsert
1 parent 65fdd49 commit 8eb1942

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

lambdas/filenameprocessor/src/audit_table.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def upsert_audit_table(
1515
queue_name: str,
1616
file_status: str,
1717
error_details: Optional[str] = None,
18-
condition_expression: str = "",
18+
condition_expression: Optional[str] = None,
1919
) -> None:
2020
"""
2121
Updates the audit table with the file details
@@ -34,11 +34,17 @@ def upsert_audit_table(
3434

3535
try:
3636
# Add to the audit table (regardless of whether it is a duplicate)
37-
dynamodb_client.put_item(
38-
TableName=AUDIT_TABLE_NAME,
39-
Item=audit_item,
40-
ConditionExpression=condition_expression,
41-
)
37+
if not condition_expression:
38+
dynamodb_client.put_item(
39+
TableName=AUDIT_TABLE_NAME,
40+
Item=audit_item,
41+
)
42+
else:
43+
dynamodb_client.put_item(
44+
TableName=AUDIT_TABLE_NAME,
45+
Item=audit_item,
46+
ConditionExpression=condition_expression,
47+
)
4248
logger.info(
4349
"%s file, with message id %s, successfully added to audit table",
4450
file_key,

lambdas/filenameprocessor/src/file_name_processor.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,10 @@ def handle_extended_attributes_file(
304304
logger.error("Error processing file '%s': %s", file_key, str(error))
305305

306306
file_status = get_file_status_for_error(error)
307-
extended_attribute_identifier = validate_extended_attributes_file_key(file_key)
308-
queue_name = extended_attribute_identifier
307+
308+
# NB if we got InvalidFileKeyError we won't have a valid queue name
309+
if not queue_name:
310+
queue_name = "unknown"
309311

310312
# Move file to archive
311313
move_file(bucket_name, file_key, f"archive/{file_key}")

0 commit comments

Comments
 (0)