From e785c12f46f5011998635b661eb8e40ba1914278 Mon Sep 17 00:00:00 2001 From: braddf Date: Mon, 28 Oct 2024 17:57:44 +0000 Subject: [PATCH] add sentry message for 422 --- pv_site_api/main.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pv_site_api/main.py b/pv_site_api/main.py index 6d84aad..b71a0e7 100644 --- a/pv_site_api/main.py +++ b/pv_site_api/main.py @@ -294,6 +294,14 @@ def post_pv_actual( generation_values_df["power_kw"] > site_capacity_kw * capacity_factor ] if len(exceeded_capacity) > 0: + # alert Sentry and return 422 validation error + sentry_sdk.capture_message( + f"Error processing generation values. " + f"One (or more) values are larger than {capacity_factor} " + f"times the site capacity of {site_capacity_kw} kWp. " + f"User: {auth['https://openclimatefix.org/email']}" + f"Site: {site_uuid}" + ) raise HTTPException( status_code=422, detail=(