mirror of
https://github.com/theroyallab/tabbyAPI.git
synced 2026-04-26 09:18:53 +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 asyncio
|
||||||
import socket
|
import socket
|
||||||
import traceback
|
import traceback
|
||||||
from fastapi import Request
|
from fastapi import HTTPException, Request
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
@@ -84,8 +84,9 @@ async def run_with_request_disconnect(
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
return call_task.result()
|
return call_task.result()
|
||||||
except (asyncio.CancelledError, asyncio.InvalidStateError):
|
except (asyncio.CancelledError, asyncio.InvalidStateError) as ex:
|
||||||
handle_request_disconnect(disconnect_message)
|
handle_request_disconnect(disconnect_message)
|
||||||
|
raise HTTPException(422, disconnect_message) from ex
|
||||||
|
|
||||||
|
|
||||||
def is_port_in_use(port: int) -> bool:
|
def is_port_in_use(port: int) -> bool:
|
||||||
|
|||||||
Reference in New Issue
Block a user