From ec144d17eb0bcebe14eb11b4d9d58181c389a5d2 Mon Sep 17 00:00:00 2001 From: Rajat Ahuja Date: Wed, 15 Oct 2025 11:44:37 -0400 Subject: [PATCH] fix: filter out fastapi validation error from sentry --- src/sentry.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/sentry.py b/src/sentry.py index 7ad467f1..e1fae034 100644 --- a/src/sentry.py +++ b/src/sentry.py @@ -6,6 +6,7 @@ from collections.abc import Sequence from typing import TYPE_CHECKING import sentry_sdk +from fastapi.exceptions import RequestValidationError from pydantic import ValidationError from src.config import settings @@ -27,7 +28,7 @@ def _filter_sentry_event(event: Event, hint: Hint | None) -> Event | None: _, exc_value, _ = exc_info if isinstance( - exc_value, HonchoException | ValidationError + exc_value, HonchoException | ValidationError | RequestValidationError ): # Filters out HonchoExceptions and ValidationErrors (typically coming from Pydantic) return None @@ -44,6 +45,11 @@ def initialize_sentry( *, integrations: Sequence[Integration], ) -> None: + """Initialize Sentry SDK with project settings. + + Args: + integrations: Sentry SDK integrations to enable (e.g., Starlette, FastAPI). + """ sentry_sdk.init( dsn=settings.SENTRY.DSN, enable_tracing=True,