{"record":{"id":"fbb9f2571c293971","repo":"crewAIInc/crewAI","slug":"unexpected-error-e-s","errorCode":null,"errorMessage":"Unexpected error: {e!s}","messagePattern":"Unexpected error: (.+?)","errorType":"exception","errorClass":"BedrockAgentError","httpStatus":null,"severity":"error","filePath":"lib/crewai-tools/src/crewai_tools/aws/bedrock/agents/invoke_agent_tool.py","lineNumber":177,"sourceCode":"                )\n\n            return completion\n\n        except ClientError as e:\n            error_code = \"Unknown\"\n            error_message = str(e)\n\n            # Try to extract error code if available\n            if hasattr(e, \"response\") and \"Error\" in e.response:\n                error_code = e.response[\"Error\"].get(\"Code\", \"Unknown\")\n                error_message = e.response[\"Error\"].get(\"Message\", str(e))\n\n            raise BedrockAgentError(f\"Error ({error_code}): {error_message}\") from e\n        except BedrockAgentError:\n            # Re-raise BedrockAgentError exceptions\n            raise\n        except Exception as e:\n            raise BedrockAgentError(f\"Unexpected error: {e!s}\") from e\n","sourceCodeStart":159,"sourceCodeEnd":178,"githubUrl":"https://github.com/crewAIInc/crewAI/blob/754d7323beb2fd042e33444a115ea2d5a47193f0/lib/crewai-tools/src/crewai_tools/aws/bedrock/agents/invoke_agent_tool.py#L159-L178","documentation":"A BedrockAgentError raised as the catch-all for any non-ClientError, non-BedrockAgentError exception during _run (e.g. AttributeError, KeyError, TypeError, network errors from the stream). The original exception is chained with `from e`, and its str() is embedded after 'Unexpected error:'.","triggerScenarios":"Programming/environment errors inside _run: unexpected None in the response dict, a KeyError reading a missing response field, socket errors mid-stream that botocore does not classify as ClientError, or issues serializing the query.","commonSituations":"Library bugs against new AWS response shapes, partial network failures, or incompatible boto3 versions producing different event objects. The chained traceback (the `from e` cause) is essential to diagnose.","solutions":["Look at the chained cause in the traceback — the true exception type and line are there, not in the wrapper message.","Upgrade boto3 and crewai-tools to current versions.","If it reproduces, capture the raw response (wrap the call, log response keys) and report with the traceback.","Retry once if the cause looks transient (connection reset)."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    result = tool._run(query)\nexcept BedrockAgentError as e:\n    cause = e.__cause__  # the real exception — inspect its type/traceback\n    logger.exception(\"Bedrock tool crashed: %r\", cause)\n    raise","preventionTips":["Always inspect e.__cause__ — the wrapper message alone is not diagnostic.","Pin boto3/crewai-tools versions that are tested together.","Log full tracebacks for any 'Unexpected error' so the root cause is not lost."],"tags":["aws","bedrock","runtime","unexpected","wrapper"],"backgroundTag":null,"analyzedSha":"754d7323beb2fd042e33444a115ea2d5a47193f0","analyzedAt":"2026-08-15T04:06:56.746Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}