Repository navigation
fix(bedrock): let non-InvokeError exceptions propagate from _invoke inference-profile branch (#3653) - #3794
fix(bedrock): let non-InvokeError exceptions propagate from _invoke inference-profile branch (#3653)#3794Taranum01 wants to merge 2 commits into
Conversation
Mairuis
left a comment
There was a problem hiding this comment.
The exception-handling change is small, but this plugin release is missing a top-level models/bedrock/manifest.yaml version bump and a non-empty ## Release Notes section in the PR description. Please update the branch against current main and add both before the next CI run. #3795 also contains these same Bedrock changes; please keep the two PR scopes separate.
e92beea to
cd7fceb
Compare
|
All three points addressed in this force-push:
|
…nference-profile branch (langgenius#3653) The _invoke inference-profile branch in models/llm/llm.py ended with a bare `except Exception as e: raise InvokeError(str(e))`. A NameError, TypeError, KeyError, or any other non-InvokeError exception raised inside the try block (by _get_model_info, get_inference_profile_info, _generate_with_converse, or any of the dict accessors) surfaced to the caller as a generic InvokeError whose message contained the original exception string, hiding the root cause and traceback. This is the same anti-pattern that PR langgenius#3565 (issue langgenius#3564) fixed in _generate, and PR langgenius#3661 (issue langgenius#3661) fixed in _generate_with_converse. The fix mirrors both: - except (ClientError, KeyError) as ex: Real AWS-boto3 client errors and dict-access KeyErrors are still wrapped as InvokeError so the operator sees the message ("ResourceNotFoundException: ..." etc.). - except Exception as ex: Unknown errors (NameError, TypeError, AttributeError, ...) re-raise verbatim so the operator sees the real traceback instead of a misleading InvokeError. `tests/test_inference_profile_exceptions.py` (new) covers the three new branches end-to-end against the real BedrockLargeLanguageModel class. The first test asserts the central invariant the fix preserves: a NameError raised inside the inference-profile branch propagates as NameError (not InvokeError). The second and third tests assert that boto3 ClientError and KeyError are still wrapped as InvokeError so the operator sees the bad-key/bad-resource message. All three tests pass. `uv run pytest tests/` is the run command and uses an empty AIModelEntity list (no real model schemas) so the LLM constructor doesn't try to resolve real predefined models — the test only exercises the error-handling branches. Low — strictly additive to the existing _invoke exception handler. The only behavior change is that unknown errors now propagate verbatim instead of being silently wrapped as InvokeError. The boto3 ClientError path and the KeyError path both still surface as InvokeError with the original message, so operators who rely on that contract see no change.
cd7fceb to
ed5c458
Compare
|
Thank you for your contribution, @Taranum01! This PR currently has merge conflicts with If these changes are still wanted, they can be folded into #4095 when you update it. |
Fixes #3653.
Problem
models/llm/llm.py_invoke(inference-profile branch, lines 240-243) wrapped the entire branch in a bareexcept Exceptionand re-raised as a genericInvokeError:A
NameError,TypeError,KeyError, or any other non-InvokeErrorexception raised inside the try block (by_get_model_info,get_inference_profile_info,_generate_with_converse, or any of the dict accessors) surfaced as a genericInvokeErrorwhose message contained the original exception string, hiding the root cause and traceback.This is the same anti-pattern that PR #3565 (issue #3564) fixed in
_generate, and PR #3661 (issue #3661) fixed in_generate_with_converse. The fix mirrors both.Fix
Tests
models/bedrock/tests/test_inference_profile_exceptions.py(new) covers the three new branches end-to-end against the realBedrockLargeLanguageModelclass.models/bedrock/tests/conftest.pystubs the AIModelEntity dependency so the LLM constructor doesn't try to resolve real predefined models — the tests only exercise the error-handling branches.The central invariant the first test pins: a
NameErrorraised inside the inference-profile branch propagates asNameError(notInvokeError) — i.e. real bugs surface, not silent wrappers.Risk
Low — strictly additive to the existing _invoke exception handler. The only behavior change is that unknown errors now propagate verbatim instead of being silently wrapped as InvokeError. The boto3 ClientError path and the KeyError path both still surface as InvokeError with the original message, so operators who rely on that contract see no change.
Release Notes
_invoke's inference-profile branch asInvokeError. ANameError/TypeError/KeyError(or any otherException) raised by_get_model_info,get_inference_profile_info,_generate_price_info, or the converse-stream call now propagates verbatim, so real bugs in the inference-profile path surface instead of being silently re-raised as a genericInvokeError. TheClientError(boto3 / AWS) path is unchanged and still surfaces asInvokeErrorwith the original message. Bumps the bedrock plugin from 0.0.89 → 0.0.90.