You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Unhandled exceptions in Flask routes return a 500 without recording the exception in telemetry #3983
When a Flask route raises an exception that no other handler catches, response_generic_error in policyengine_api/routes/error_routes.py returns a 500 JSON response but never passes the exception to the observability runtime. The central log bucket then has a request.completed record with outcome=error and no record of which exception caused it: no error.type and no stack.
In a 7-day sample of 400 ERROR records from the central bucket, only 50 carried error.type. At least 134 were request.completed records with outcome=error and no exception details. Those failures can't be grouped by exception type, which a planned daily error report needs.
Change
Add record_unhandled_exception() to policyengine_api.observability. It calls runtime.record_exception(error, handled=False, status_code=...) and suppresses any exception the telemetry call raises, so recording can never change the response.
Call it from response_generic_error before the 500 response is built. HTTP exceptions (404, 405 and others) go through response_http_exception and are not recorded.
Effects on telemetry:
Each Flask 500 adds one exception.recorded ERROR record with error.type, the message and the stack.
Each such 500 adds two policyengine.error.count points: the new one with operation.kind=unhandled and the existing one with operation.kind=request. The error-rate alert and dashboard now count only operation.kind values request and operation, so each failure counts once there. The alert has no notification channels, so no one is paged.
Activity