Skip to content

Commit 9b371b8

Browse files
committed
feat(err_license): testing
1 parent 1e7562b commit 9b371b8

File tree

3 files changed

+33
-3
lines changed

3 files changed

+33
-3
lines changed

.github/workflows/integration_tests_powershell.yml

Whitespace-only changes.

src/uipath_langchain/_cli/_runtime/_runtime.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
UiPathBaseRuntime,
1515
UiPathErrorCategory,
1616
UiPathRuntimeResult,
17+
UiPathRuntimeError,
1718
)
1819

1920
from ..._utils import _instrument_traceable_attributes
@@ -113,6 +114,15 @@ async def execute(self) -> Optional[UiPathRuntimeResult]:
113114
self._pretty_print(stream_chunk)
114115
final_chunk = stream_chunk
115116

117+
#
118+
raise UiPathRuntimeError(
119+
code="LICENSE_NOT_AVAILABLE",
120+
title=body.get('title', 'License Not Available'),
121+
detail=body.get('detail', 'License not available for this service'),
122+
category=UiPathErrorCategory.DEPLOYMENT,
123+
prefix="UIPATH"
124+
)
125+
116126
self.context.output = self._extract_graph_result(final_chunk, graph)
117127
else:
118128
# Execute the graph normally at runtime
@@ -135,6 +145,8 @@ async def execute(self) -> Optional[UiPathRuntimeResult]:
135145
except Exception as e:
136146
if isinstance(e, LangGraphRuntimeError):
137147
raise
148+
if isinstance(e, UiPathRuntimeError):
149+
raise
138150

139151
detail = f"Error: {str(e)}"
140152

src/uipath_langchain/_utils/_request_mixin.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import os
55
import time
66
from typing import Any, Dict, List, Mapping, Optional
7-
7+
from contextlib import suppress
88
import httpx
99
import openai
1010
from langchain_core.embeddings import Embeddings
@@ -25,7 +25,7 @@
2525
get_uipath_token_header,
2626
)
2727
from uipath_langchain._utils._sleep_policy import before_sleep_log
28-
28+
from uipath._cli._runtime._contracts import UiPathRuntimeError, UiPathErrorCategory
2929

3030
def get_from_uipath_url():
3131
url = os.getenv("UIPATH_URL")
@@ -234,7 +234,7 @@ async def _arequest(
234234
# Handle HTTP errors and map them to OpenAI exceptions
235235
try:
236236
response.raise_for_status()
237-
except httpx.HTTPStatusError as err:
237+
except httpx.HTTPStatusError as err:
238238
if self.logger:
239239
self.logger.error(
240240
"Error querying LLM: %s (%s)",
@@ -348,6 +348,24 @@ def _make_status_error(
348348
return openai.AuthenticationError(err_msg, response=response, body=data)
349349

350350
if response.status_code == 403:
351+
# Check if this is a license-specific error
352+
if isinstance(body, dict):
353+
title = body.get('title', '').lower()
354+
detail = body.get('detail', '').lower()
355+
356+
# Smart detection of license errors
357+
if ('license' in title or 'license' in detail) and \
358+
('not available' in title or 'not available' in detail or
359+
'unavailable' in title or 'unavailable' in detail):
360+
# Raise UiPathRuntimeError for license issues
361+
raise UiPathRuntimeError(
362+
code="LICENSE_NOT_AVAILABLE",
363+
title=body.get('title', 'License Not Available'),
364+
detail=body.get('detail', 'License not available for this service'),
365+
category=UiPathErrorCategory.DEPLOYMENT,
366+
prefix="UIPATH"
367+
)
368+
351369
return openai.PermissionDeniedError(err_msg, response=response, body=data)
352370

353371
if response.status_code == 404:

0 commit comments

Comments
 (0)