mirror of
https://github.com/theroyallab/tabbyAPI.git
synced 2026-03-15 00:07:28 +00:00
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:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user