Merge pull request #3989 from pharindoko/main

fix(bedrock): raise nested error response
This commit is contained in:
Krish Dholakia 2024-06-04 17:35:42 -07:00 committed by GitHub
commit 0e023d8931
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -284,7 +284,11 @@ class BedrockLLM(BaseLLM):
) = params_to_check ) = params_to_check
### CHECK STS ### ### CHECK STS ###
if aws_web_identity_token is not None and aws_role_name is not None and aws_session_name is not None: if (
aws_web_identity_token is not None
and aws_role_name is not None
and aws_session_name is not None
):
oidc_token = get_secret(aws_web_identity_token) oidc_token = get_secret(aws_web_identity_token)
if oidc_token is None: if oidc_token is None:
@ -293,9 +297,7 @@ class BedrockLLM(BaseLLM):
status_code=401, status_code=401,
) )
sts_client = boto3.client( sts_client = boto3.client("sts")
"sts"
)
# https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRoleWithWebIdentity.html # https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRoleWithWebIdentity.html
# https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/sts/client/assume_role_with_web_identity.html # https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/sts/client/assume_role_with_web_identity.html
@ -1007,7 +1009,7 @@ class BedrockLLM(BaseLLM):
response.raise_for_status() response.raise_for_status()
except httpx.HTTPStatusError as err: except httpx.HTTPStatusError as err:
error_code = err.response.status_code error_code = err.response.status_code
raise BedrockError(status_code=error_code, message=response.text) raise BedrockError(status_code=error_code, message=err.response.text)
except httpx.TimeoutException as e: except httpx.TimeoutException as e:
raise BedrockError(status_code=408, message="Timeout error occurred.") raise BedrockError(status_code=408, message="Timeout error occurred.")