From cc557f7898e3b02128557ce8cf3ec56b5b9a5de8 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Thu, 16 Nov 2023 18:01:57 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(store.py):=20handle=20HTTPSt?= =?UTF-8?q?atusError=20exceptions=20and=20raise=20appropriate=20HTTPExcept?= =?UTF-8?q?ions=20with=20corresponding=20status=20codes=20and=20details?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/api/v1/store.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/backend/langflow/api/v1/store.py b/src/backend/langflow/api/v1/store.py index 90cab1001..afaaa9ee9 100644 --- a/src/backend/langflow/api/v1/store.py +++ b/src/backend/langflow/api/v1/store.py @@ -4,6 +4,7 @@ from uuid import UUID from fastapi import APIRouter, Depends, HTTPException, Query from httpx import HTTPStatusError + from langflow.services.auth import utils as auth_utils from langflow.services.database.models.user.user import User from langflow.services.deps import get_settings_service, get_store_service @@ -193,4 +194,9 @@ async def like_component( return UsersLikesResponse(likes_count=likes_count, liked_by_user=result) except Exception as exc: + if isinstance(exc, HTTPStatusError): + if exc.response.status_code == 403: + raise HTTPException(status_code=403, detail="Forbidden") + elif exc.response.status_code == 401: + raise HTTPException(status_code=401, detail="Unauthorized") raise HTTPException(status_code=500, detail=str(exc))