Skip to content

Commit c395232

Browse files
committed
Remove stack traces from intentional 4xx exception logging
ForbiddenError403, BadRequestError400, and MultiPartParserError are intentional error responses, not unexpected failures. Logging them with exc_info produced misleading stack traces that looked like bugs and created noise in error tracking tools like Sentry. Keep the WARNING messages (they have diagnostic value) but drop the stack traces, consistent with how FormFieldMissingError already works. SuspiciousOperationError400 and unhandled 500s retain their stack traces.
1 parent d083155 commit c395232

File tree

1 file changed

+0
-3
lines changed

1 file changed

+0
-3
lines changed

plain/plain/internal/handlers/exception.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ def response_for_exception(request: Request, exc: Exception) -> ResponseBase:
3737
"Forbidden (Permission denied): %s",
3838
request.path,
3939
extra={"status_code": response.status_code, "request": request},
40-
exc_info=exc,
4140
)
4241

4342
elif isinstance(exc, MultiPartParserError):
@@ -48,7 +47,6 @@ def response_for_exception(request: Request, exc: Exception) -> ResponseBase:
4847
"Bad request (Unable to parse request body): %s",
4948
request.path,
5049
extra={"status_code": response.status_code, "request": request},
51-
exc_info=exc,
5250
)
5351

5452
elif isinstance(exc, BadRequestError400):
@@ -60,7 +58,6 @@ def response_for_exception(request: Request, exc: Exception) -> ResponseBase:
6058
str(exc),
6159
request.path,
6260
extra={"status_code": response.status_code, "request": request},
63-
exc_info=exc,
6461
)
6562
elif isinstance(exc, SuspiciousOperationError400):
6663
# The request logger receives events for any problematic request

0 commit comments

Comments
 (0)