Skip to content

fix(errors): categorize unresolvable Bedrock model id as Deployment#942

Open
cotovanu-cristian wants to merge 1 commit into
mainfrom
fix/validate-bedrock-model-resolution
Open

fix(errors): categorize unresolvable Bedrock model id as Deployment#942
cotovanu-cristian wants to merge 1 commit into
mainfrom
fix/validate-bedrock-model-resolution

Conversation

@cotovanu-cristian

Copy link
Copy Markdown
Collaborator

Problem

A Bedrock model id with no provider segment (no dot to split provider from model) cannot be mapped to a known Bedrock provider. langchain_aws derives the provider from the model id by splitting on .; a bare alias yields the whole alias as the "provider", which is not in the supported set. This only fails deep at invoke time with an opaque NotImplementedError ("Provider model does not support chat"), so it buckets as an Unknown runtime error rather than the deployment misconfiguration it is.

Fix

Validate the model id at UiPathChatBedrock / UiPathChatBedrockConverse construction. A _resolve_bedrock_provider helper mirrors the library's own region-prefix-aware split; if the resolved provider is not a known Bedrock provider, raise AgentStartupError(LLM_INVALID_MODEL) categorized as Deployment. ARNs (which carry no inline provider) are left for langchain_aws to validate against an explicit provider.

This fails fast at startup with an attributable, Deployment-categorized error instead of an opaque Unknown at invoke time.

Tests

tests/chat/test_bedrock.py::TestModelResolutionValidation — an unresolvable synthetic model id raises a Deployment-categorized AgentStartupError (both invoke and converse variants); a known model id still constructs.

🤖 Generated with Claude Code

A model id with no provider segment (no dot to split provider from model)
cannot be mapped to a known Bedrock provider. langchain_aws then carries the
whole id forward as the "provider" and only fails at invoke time with an
opaque NotImplementedError ("Provider <id> model does not support chat"),
which buckets as an Unknown runtime error.

Validate the model id at UiPathChatBedrock / UiPathChatBedrockConverse
construction and raise a typed AgentStartupError(LLM_INVALID_MODEL) categorized
as Deployment, so a misconfigured model is attributable instead of opaque.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 25, 2026 16:04

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

This PR improves Bedrock model-id validation for the legacy Bedrock chat wrappers so that unresolvable model IDs fail fast at construction time with a Deployment-categorized AgentStartupError(LLM_INVALID_MODEL), instead of surfacing later as an opaque NotImplementedError during invocation.

Changes:

  • Added provider-resolution + validation helpers for Bedrock model IDs and raise a Deployment-categorized startup error for unsupported providers.
  • Wired model-id validation into UiPathChatBedrock and UiPathChatBedrockConverse constructors.
  • Added pytest coverage asserting invalid IDs raise a Deployment error and valid IDs still construct.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/uipath_langchain/chat/_legacy/bedrock.py Adds provider resolution/validation and raises a structured Deployment startup error during Bedrock wrapper initialization.
tests/chat/test_bedrock.py Adds tests ensuring invalid model IDs are categorized as Deployment at construction time.

Comment on lines +91 to +92
if model_id.startswith("arn"):
return None
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
88.9% Coverage on New Code (required ≥ 90%)

See analysis details on SonarQube Cloud

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