Skip to content

Commit 9832a2e

Browse files
committed
fix(publication_manager_service): Add evaluation result validation and remove unused metric
- Add validation for evaluation_result to ensure only "APPROVED" or "DECLINED" values are processed - Return early with skip message when unknown evaluation result is encountered - Log warning when evaluation result is invalid for debugging purposes - Remove unused PropertiesAdded metric that was not being utilized - Improve robustness by preventing invalid data from being written to DynamoDB
1 parent d2ee99a commit 9832a2e

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

unicorn_web/src/publication_manager_service/publication_evaluation_event_handler.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,18 @@ def publication_approved(event_detail, errors):
7474

7575
property_id = event_detail.property_id
7676
evaluation_result = event_detail.evaluation_result
77+
78+
valid_results = {"APPROVED", "DECLINED"}
79+
if evaluation_result.upper() not in valid_results:
80+
logger.warning(f"Unknown evaluation_result '{evaluation_result}'; skipping DynamoDB update")
81+
return {"result": "Skipped — unknown evaluation result"}
82+
7783
country, city, street, number = property_id.split("/")
7884

7985
pk_details = f"{country}#{city}".replace(" ", "-").lower()
8086
pk = f"PROPERTY#{pk_details}"
8187
sk = f"{street}#{str(number)}".replace(" ", "-").lower()
8288

83-
metrics.add_metric(name="PropertiesAdded", unit=MetricUnit.Count, value=1)
84-
8589
logger.info(f"Storing new property in DynamoDB with PK {pk} and SK {sk}")
8690
dynamodb_response = table.update_item(
8791
Key={

0 commit comments

Comments
 (0)