From 0547dd5d76a426da37c10542a5b87181bd08cefc Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Thu, 16 Nov 2023 10:57:02 -0300 Subject: [PATCH] Handle 401 Unauthorized error in get_components function --- src/backend/langflow/api/v1/store.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/backend/langflow/api/v1/store.py b/src/backend/langflow/api/v1/store.py index 58dc30b70..609e76b74 100644 --- a/src/backend/langflow/api/v1/store.py +++ b/src/backend/langflow/api/v1/store.py @@ -142,6 +142,8 @@ async def get_components( except HTTPStatusError as exc: if exc.response.status_code == 403: raise ValueError("You are not authorized to access this public resource") + elif exc.response.status_code == 401: + raise ValueError("You are not authorized to access this resource. Please check your API key.") if store_api_Key and result: # Now, from the result, we need to get the components @@ -161,6 +163,8 @@ async def get_components( if exc.response.status_code == 403: raise HTTPException(status_code=403, detail="Forbidden") elif isinstance(exc, ValueError): + if "Check your API key" in str(exc): + raise HTTPException(status_code=401, detail=str(exc)) raise HTTPException(status_code=403, detail=str(exc)) raise HTTPException(status_code=500, detail=str(exc))