mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-04-30 23:02:50 +00:00
fix: narrow Bedrock _init_clients except to credential errors only
The bare `except Exception` would silently swallow `TypeError`, `AttributeError`, and other real bugs in `_build_sync_client` with only a debug log. The intent is to defer on missing AWS credentials, which boto3 surfaces as `BotoCoreError` / `ClientError` (and `ValueError` for some validation paths). Catch only those; let everything else propagate so genuine failures stay loud.
This commit is contained in:
@@ -310,10 +310,14 @@ class BedrockCompletion(BaseLLM):
|
|||||||
"""Eagerly build the sync client when AWS credentials resolve,
|
"""Eagerly build the sync client when AWS credentials resolve,
|
||||||
otherwise defer so ``LLM(model="bedrock/...")`` can be constructed
|
otherwise defer so ``LLM(model="bedrock/...")`` can be constructed
|
||||||
at module import time even before deployment env vars are set.
|
at module import time even before deployment env vars are set.
|
||||||
|
|
||||||
|
Only credential/SDK errors are caught — programming errors like
|
||||||
|
``TypeError`` or ``AttributeError`` propagate so real bugs aren't
|
||||||
|
silently swallowed.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
self._client = self._build_sync_client()
|
self._client = self._build_sync_client()
|
||||||
except Exception as e:
|
except (BotoCoreError, ClientError, ValueError) as e:
|
||||||
logging.debug("Deferring Bedrock client construction: %s", e)
|
logging.debug("Deferring Bedrock client construction: %s", e)
|
||||||
self._async_exit_stack = AsyncExitStack() if AIOBOTOCORE_AVAILABLE else None
|
self._async_exit_stack = AsyncExitStack() if AIOBOTOCORE_AVAILABLE else None
|
||||||
return self
|
return self
|
||||||
|
|||||||
Reference in New Issue
Block a user