From d3678cb150c111256405ba1457cceb35041df4da Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 20 Oct 2025 23:04:16 +0300 Subject: [PATCH] fix critical http error --- common_lib/services/chat_internal.py | 23 ++++++++++++++++------- pyproject.toml | 2 +- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/common_lib/services/chat_internal.py b/common_lib/services/chat_internal.py index 75bd71e..be6a7e0 100644 --- a/common_lib/services/chat_internal.py +++ b/common_lib/services/chat_internal.py @@ -5,7 +5,12 @@ from config import settings from common_lib.utils.http_client import client -async def send_internal_message(sender: str, user_id: UUID, content: str) -> dict: +async def send_internal_message( + sender: str, + user_id: UUID, + content: str, + with_httpexception = False +) -> dict: try: response = await client.post( f"{settings.CHAT_PRIVATE_SERVICE}/internal/send", @@ -15,13 +20,17 @@ async def send_internal_message(sender: str, user_id: UUID, content: str) -> dic }) if response.status_code != 200: - raise HTTPException( - status_code=response.status_code, - detail=f"chat_private_service: {response.text}" - ) + if with_httpexception: + raise HTTPException( + status_code=response.status_code, + detail=f"chat_private_service: {response.text}" + ) + return response.status_code, f"chat_private_service: {response.text}" wrapped = response.json() - return wrapped["data"] + return 200, wrapped except httpx.RequestError as e: - raise HTTPException(status_code=status.HTTP_503_SERVICE_UNAVAILABLE, detail=f"chat_private_service unreachable: {str(e)}") + if with_httpexception: + raise HTTPException(status_code=status.HTTP_503_SERVICE_UNAVAILABLE, detail=f"chat_private_service unreachable: {str(e)}") + return 503, f"chat_private_service unreachable: {str(e)}" diff --git a/pyproject.toml b/pyproject.toml index 34ca756..57084b7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "common-lib" -version = "0.0.28" +version = "0.0.29" description = "Библиотека общих компонентов для микросервисов yobble" authors = [{ name = "cheykrym", email = "you@example.com" }] license = "MIT"