API: Fix pydantic validation errors on disconnect poll returns
Raise a 422 exception for the disconnect. This prevents pydantic errors when returning a "response" which doesn't contain anything in this case. Signed-off-by: kingbri <bdashore3@proton.me>
This commit is contained in:
parent
933404c185
commit
e20a2d504b
1 changed files with 3 additions and 2 deletions
|
|
@ -3,7 +3,7 @@
|
|||
import asyncio
|
||||
import socket
|
||||
import traceback
|
||||
from fastapi import Request
|
||||
from fastapi import HTTPException, Request
|
||||
from loguru import logger
|
||||
from pydantic import BaseModel
|
||||
from typing import Optional
|
||||
|
|
@ -84,8 +84,9 @@ async def run_with_request_disconnect(
|
|||
|
||||
try:
|
||||
return call_task.result()
|
||||
except (asyncio.CancelledError, asyncio.InvalidStateError):
|
||||
except (asyncio.CancelledError, asyncio.InvalidStateError) as ex:
|
||||
handle_request_disconnect(disconnect_message)
|
||||
raise HTTPException(422, disconnect_message) from ex
|
||||
|
||||
|
||||
def is_port_in_use(port: int) -> bool:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue