🐛 fix(chat.py): handle unauthorized error in chat websocket to return WS_1008_POLICY_VIOLATION status code and "Unauthorized" reason
This commit is contained in:
parent
418bddd322
commit
1407719f2f
1 changed files with 6 additions and 1 deletions
|
|
@ -61,7 +61,12 @@ async def chat(
|
||||||
await websocket.close(code=status.WS_1011_INTERNAL_ERROR, reason=str(exc))
|
await websocket.close(code=status.WS_1011_INTERNAL_ERROR, reason=str(exc))
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
logger.error(f"Error in chat websocket: {exc}")
|
logger.error(f"Error in chat websocket: {exc}")
|
||||||
await websocket.close(code=status.WS_1011_INTERNAL_ERROR, reason=str(exc))
|
if "Could not validate credentials" in str(exc):
|
||||||
|
await websocket.close(
|
||||||
|
code=status.WS_1008_POLICY_VIOLATION, reason="Unauthorized"
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
await websocket.close(code=status.WS_1011_INTERNAL_ERROR, reason=str(exc))
|
||||||
|
|
||||||
|
|
||||||
@router.post("/build/init/{flow_id}", response_model=InitResponse, status_code=201)
|
@router.post("/build/init/{flow_id}", response_model=InitResponse, status_code=201)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue