Skip to content

feat(licensing): normalize provider HTTP errors via provider_errors module#926

Open
vldcmp-uipath wants to merge 1 commit into
mainfrom
feat/provider-error-normalization
Open

feat(licensing): normalize provider HTTP errors via provider_errors module#926
vldcmp-uipath wants to merge 1 commit into
mainfrom
feat/provider-error-normalization

Conversation

@vldcmp-uipath

Copy link
Copy Markdown
Contributor

Summary

Refactors the provider HTTP-error handling out of licensing.py into a focused, tested chat/provider_errors.py module, and picks up the released Bedrock fix.

LLM providers behind the gateway each raise a different exception type (LangChain sometimes wraps them again), but all carry the same gateway body ({status, detail, ...}). extract_provider_error walks the __cause__ chain and reads the status + detail from whichever attribute each SDK exposes:

Provider Status Detail
OpenAI / Anthropic .status_code .body
Bedrock (UiPathAPIError via WrappedBotoClient) .status_code .body
Vertex / google.genai .code .details
Bedrock legacy (botocore) .response["ResponseMetadata"] .response["Error"]

licensing.py is now just the policy layer — it maps the normalized status to an AgentRuntimeError.

Changes

  • New src/uipath_langchain/chat/provider_errors.pyProviderError + extract_provider_error (recursive __cause__ walk, one small extractor per provider).
  • agent/exceptions/licensing.py — delegates extraction to provider_errors; keeps only the status→error-code mapping.
  • Bumps uipath-langchain-client floor to >=1.14.1 — the released version that makes the Bedrock WrappedBotoClient raise on gateway errors instead of swallowing them (previously surfaced as a misleading "No 'output' key … misconfiguration of endpoint or region" ValueError). Also fixes Vertex detail extraction, which was previously dropped.
  • New tests/chat/test_provider_errors.py — covers all provider shapes, the LangChain __cause__ wrapping, the empty no-match case, and the non-int-status false-positive guard.

Testing

pytest tests/chat/test_provider_errors.py → 7 passed.

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings June 23, 2026 11:36

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Refactors LLM Gateway provider HTTP error extraction into a dedicated provider_errors module so licensing.py can focus on mapping normalized statuses to AgentRuntimeError, while also bumping uipath-langchain-client to pick up the released Bedrock error-surfacing fix.

Changes:

  • Adds ProviderError + extract_provider_error to normalize provider SDK exception shapes (including LangChain __cause__ wrapping).
  • Simplifies raise_for_provider_http_error to delegate extraction and use gateway detail when available.
  • Bumps uipath-langchain-client minimum to >=1.14.1 and adds targeted tests for provider error normalization.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/uipath_langchain/chat/provider_errors.py Introduces normalized provider error extraction logic.
src/uipath_langchain/agent/exceptions/licensing.py Delegates provider error parsing and maps normalized status to AgentRuntimeError.
tests/chat/test_provider_errors.py Adds unit tests covering provider shapes and LangChain wrapping.
pyproject.toml Bumps package version and raises uipath-langchain-client floor to >=1.14.1.
uv.lock Updates lockfile for the version bump and dependency floor change.

Comment thread src/uipath_langchain/chat/provider_errors.py
Comment thread src/uipath_langchain/chat/provider_errors.py
Comment thread src/uipath_langchain/chat/provider_errors.py
Comment thread src/uipath_langchain/agent/exceptions/licensing.py
Comment thread tests/chat/test_provider_errors.py
@vldcmp-uipath vldcmp-uipath force-pushed the feat/provider-error-normalization branch 4 times, most recently from 51bb902 to 38159e8 Compare June 23, 2026 13:16
…odule

Extract the per-provider exception parsing out of licensing.py into a focused
chat/provider_errors.py module. extract_provider_error walks the __cause__ chain
and reads the HTTP status + gateway `detail` from whichever attribute each SDK
exposes (OpenAI/Anthropic .body, Vertex .details, Bedrock UiPathAPIError .body,
legacy botocore .response), returning a normalized ProviderError. licensing.py
now just maps that status to an AgentRuntimeError.

Bumps uipath-langchain-client to 1.14.1, which makes the Bedrock path raise on
gateway errors instead of swallowing them.

Adds tests/chat/test_provider_errors.py covering all provider shapes, the
LangChain __cause__ wrapping, the empty no-match case, and the non-int-status
false-positive guard.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vldcmp-uipath vldcmp-uipath force-pushed the feat/provider-error-normalization branch from 38159e8 to 59a6c50 Compare June 23, 2026 13:20
@sonarqubecloud

Copy link
Copy Markdown

@@ -0,0 +1,95 @@
"""Normalize LLM provider HTTP errors into a common shape.

Providers behind the LLM Gateway each raise a different exception type, but all

@radu-mocanu radu-mocanu Jun 23, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

should uipath-langchain know about llm gateway?
I think this should be the concern of the upstream clients lib

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.

3 participants