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
return HTTPException in async_db_request_handler #67
Hello,
Problem, when exception raised in service with async_db_request_handler decorator, it return HTTPException, which FastAPI can't serialize and raised another exception
fastapi.exceptions.ResponseValidationError: 1 validation errors:
{'loc': ('response',), 'msg': 'value is not a valid dict', 'type': 'type_error.dict'}
I believe you are correct. When the service layer return an exception, then the controller does not know that an error was raised and it breaking the exceptions chain. I will work on pr that fix it.
Resolved by the DI/runtime rewrite in #125. db_request_handler and async_db_request_handler now re-raise existing HTTPException instances and convert unexpected exceptions with raise HTTPException(...) rather than returning an exception object for response serialization.
The original async failure pattern was reproduced against current main and correctly raises an HTTP 500 exception. Closing as completed.
Activity
ItayTheDar commentedon Jun 11, 2024
@nurlybek-dev Hi!
I believe you are correct. When the service layer return an exception, then the controller does not know that an error was raised and it breaking the exceptions chain. I will work on pr that fix it.
ItayTheDar commentedon Jul 28, 2026
Resolved by the DI/runtime rewrite in #125.
db_request_handlerandasync_db_request_handlernow re-raise existingHTTPExceptioninstances and convert unexpected exceptions withraise HTTPException(...)rather than returning an exception object for response serialization.The original async failure pattern was reproduced against current
mainand correctly raises an HTTP 500 exception. Closing as completed.