Skip to content

fix: check can consume licensing error [JAR-9330]#725

Merged
andrewwan-uipath merged 1 commit intomainfrom
task/cas-licensing-error-propagation
Mar 26, 2026
Merged

fix: check can consume licensing error [JAR-9330]#725
andrewwan-uipath merged 1 commit intomainfrom
task/cas-licensing-error-propagation

Conversation

@andrewwan-uipath
Copy link
Copy Markdown
Contributor

@andrewwan-uipath andrewwan-uipath commented Mar 24, 2026

https://uipath.atlassian.net/browse/JAR-9330

  • Detect licensing (canConsume) errors from LLM Gateway and raise a structured LangGraphRuntimeError(LICENSE_NOT_AVAILABLE) so the bridge can map it to a user-facing message for CAS
Screenshot 2026-03-24 at 4 14 59 PM

Comment on lines +31 to +37
raise LangGraphRuntimeError(
code=LangGraphErrorCode.LICENSE_NOT_AVAILABLE,
title=body.get("title", "License not available"),
detail=body.get("detail", "License not available for LLM usage."),
category=UiPathErrorCategory.DEPLOYMENT,
status=403,
) from e
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not AgentRuntimeError? I guess we wanted to reuse the existing error code?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ye I'm just reusing the existing error code we had

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated so we use AgentRuntimeError

Comment on lines +21 to +26
if getattr(e, "status_code", None) != 403:
return

body = getattr(e, "body", None)
if not isinstance(body, dict):
return
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was this tested for all providers? While the payload itself is from agenthub and not the provider, the exception formats themselves should still be different (OpenAI's error class vs botocore vs google's)
surprised they all have body

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to test the other ones as well, good catch

# LLM errors arrive as provider-specific exceptions (OpenAI, Bedrock, etc.)
# Don't have a good way to extract common error info now, have this generic mapper
# so CAS can detect and show a descriptive message to the user
raise_if_licensing_error(e)
Copy link
Copy Markdown
Contributor

@andreitava-uip andreitava-uip Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this is a bit too specific, since all we care about is the status code for now why not extract the status code (ignoring the other error info) and re-raise as an EnrichedException/ UiPathBaseRuntimeError subclass. Doing it specifically for licensing error is not very extensible

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated, we now extract the HTTP status code from any provider exception and re-raises as an AgentRuntimeError with the status code preserved

@andrewwan-uipath andrewwan-uipath force-pushed the task/cas-licensing-error-propagation branch from 398a922 to 2dcd1a4 Compare March 26, 2026 00:32
Comment on lines +80 to +85
raise AgentRuntimeError(
code=code,
title=f"LLM provider returned HTTP {sc}",
detail=str(e),
category=category,
status=sc,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: since we have specific error codes we could set meaningful title and details as well. The logic for the exception_mapper is to not touch AgentRuntimeErrors and assume that they are already correct with meaningful messages.

Fine to leave this as a further improvement

@andrewwan-uipath andrewwan-uipath force-pushed the task/cas-licensing-error-propagation branch from 2dcd1a4 to cd388ec Compare March 26, 2026 17:14
@andrewwan-uipath andrewwan-uipath merged commit 3d0afd8 into main Mar 26, 2026
42 checks passed
@andrewwan-uipath andrewwan-uipath deleted the task/cas-licensing-error-propagation branch March 26, 2026 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants