fix: check can consume licensing error [JAR-9330]#725
Conversation
| 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 |
There was a problem hiding this comment.
why not AgentRuntimeError? I guess we wanted to reuse the existing error code?
There was a problem hiding this comment.
ye I'm just reusing the existing error code we had
There was a problem hiding this comment.
updated so we use AgentRuntimeError
| if getattr(e, "status_code", None) != 403: | ||
| return | ||
|
|
||
| body = getattr(e, "body", None) | ||
| if not isinstance(body, dict): | ||
| return |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Updated, we now extract the HTTP status code from any provider exception and re-raises as an AgentRuntimeError with the status code preserved
398a922 to
2dcd1a4
Compare
| raise AgentRuntimeError( | ||
| code=code, | ||
| title=f"LLM provider returned HTTP {sc}", | ||
| detail=str(e), | ||
| category=category, | ||
| status=sc, |
There was a problem hiding this comment.
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
2dcd1a4 to
cd388ec
Compare
https://uipath.atlassian.net/browse/JAR-9330
LangGraphRuntimeError(LICENSE_NOT_AVAILABLE)so the bridge can map it to a user-facing message for CAS