Skip to content

Commit

Permalink
fixed validation error with bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
denisov-vlad committed Jul 24, 2024
1 parent f2c5908 commit 93b3878
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions simple_snowplow/plugins/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,13 @@ def init_logging():

async def validation_exception_handler(request: Request, exc: RequestValidationError):
error_data = exc.errors()
logger.warning(
f"Validation error: {orjson.dumps(error_data)}, body: {orjson.dumps(exc.body)}",
)

try:
body = orjson.dumps(exc.body)
except TypeError:
body = exc.body

logger.warning(f"Validation error: {orjson.dumps(error_data)}, body: {body}")
return JSONResponse(
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
content=jsonable_encoder(error_data),
Expand Down

0 comments on commit 93b3878

Please sign in to comment.