Skip to content

Commit 0b8bcd1

Browse files
committed
Map 400 to 401 on s2s (#1)
1 parent 2784a58 commit 0b8bcd1

6 files changed

Lines changed: 26 additions & 16 deletions

File tree

.github/workflows/cd-langchain.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ name: Publish uipath-langchain-client to PyPI
22

33
on:
44
push:
5-
tags:
6-
# Publish on any tag starting with `langchain-v`, e.g., langchain-v1.0.0
7-
- langchain-v*
5+
branches:
6+
- main
7+
paths:
8+
- 'packages/uipath_langchain_client/src/uipath_langchain_client/__version__.py'
89
workflow_dispatch:
910

1011
jobs:

.github/workflows/cd.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ name: Publish uipath-llm-client to PyPI
22

33
on:
44
push:
5-
tags:
6-
# Publish on any tag starting with a `v`, e.g., v1.0.0
7-
- v*
5+
branches:
6+
- main
7+
paths:
8+
- 'src/uipath_llm_client/__version__.py'
89
workflow_dispatch:
910

1011
jobs:

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
All notable changes to `uipath_llm_client` (core package) will be documented in this file.
44

5+
## [1.0.1] - 2025-01-30
6+
7+
### Bug Fixes
8+
- Map 400 Bad requests on S2S to 401 Unauthorized for better readability
9+
510
## [1.0.0] - 2025-01-30
611

712
### Official Release
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
__titile__ = "UiPath LLM Client"
22
__description__ = "A Python client for interacting with UiPath's LLM services."
3-
__version__ = "1.0.0"
3+
__version__ = "1.0.1"

src/uipath_llm_client/settings/llmgateway/auth.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
from collections.abc import Generator
22

3-
from httpx import Auth, Client, HTTPStatusError, Request, Response
3+
from httpx import Auth, Client, Request, Response
44

55
from uipath_llm_client.settings.llmgateway.settings import LLMGatewayBaseSettings
66
from uipath_llm_client.settings.llmgateway.utils import LLMGatewayEndpoints
77
from uipath_llm_client.settings.utils import SingletonMeta
8-
from uipath_llm_client.utils.exceptions import UiPathAPIError
8+
from uipath_llm_client.utils.exceptions import UiPathAPIError, UiPathAuthenticationError
99

1010

1111
class LLMGatewayS2SAuth(Auth, metaclass=SingletonMeta):
@@ -39,10 +39,15 @@ def get_llmgw_token_header(
3939
)
4040
with Client() as http_client:
4141
response = http_client.post(url_get_token, data=token_credentials)
42-
try:
43-
response.raise_for_status()
44-
except HTTPStatusError as e:
45-
raise UiPathAPIError.from_response(e.response)
42+
if response.is_client_error:
43+
raise UiPathAuthenticationError(
44+
message="Failed to authenticate with LLM Gateway, invalid credentials",
45+
request=response.request,
46+
response=response,
47+
body=response.json(),
48+
)
49+
elif response.is_error:
50+
raise UiPathAPIError.from_response(response)
4651
llmgw_token_header = response.json().get("access_token")
4752
return llmgw_token_header
4853

tests/core/test_base_client.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -506,9 +506,7 @@ def test_auth_flow_refreshes_on_401(self, agenthub_env_vars):
506506
settings = AgentHubSettings()
507507

508508
# Mock _get_access_token to return a new token on refresh
509-
with patch.object(
510-
AgentHubAuth, "_get_access_token", return_value="initial-token"
511-
):
509+
with patch.object(AgentHubAuth, "_get_access_token", return_value="initial-token"):
512510
auth = AgentHubAuth(settings=settings)
513511

514512
request = Request("GET", "https://example.com")

0 commit comments

Comments
 (0)