Skip to content

Surface underlying error on bedrock integration instead of assuming connection issue #1672

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
bglearning opened this issue Apr 25, 2025 · 1 comment
Labels
contributions wanted! Looking for external contributions feature request Ideas to improve an integration P2

Comments

@bglearning
Copy link

In the bedrock components, document_embeder.py#L219, generator.py#L236, there is an exception catch on run which then produces a message about it being a connection error regardless of the underlying issue.

except ClientError as exception:
    msg = (
        f"Could not connect to Amazon Bedrock model {self.model}. "
        f"Make sure your AWS environment is configured correctly, "
        f"the model is available in the configured AWS region, and you have access."
    )
    raise AmazonBedrockInferenceError(msg) from exception

This assumes it's always the connection issue and is misleading in cases there is another underlying issue (e.g. the token count being too high).

Desired behavior

It should either surface the underlying error directly or configure the message to be specific to possible / common issues.

In this sense, the ranker handling seems to be better:

ranker.py#L254

@bglearning bglearning added the feature request Ideas to improve an integration label Apr 25, 2025
@bilgeyucel
Copy link
Contributor

For more context, I got this issue while running AmazonBedrockTextEmbedder with a short query as well

from haystack_integrations.components.embedders.amazon_bedrock import AmazonBedrockTextEmbedder
embedder_model = "amazon.titan-embed-text-v2:0" # Could not connect to Amazon Bedrock model amazon.titan-embed-text-v2:0. Make sure your AWS environment is configured correctly, the model is available in the configured AWS region, and you have access.

embedder = AmazonBedrockTextEmbedder(model=embedder_model)
embedder.run(text="This is a test query")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributions wanted! Looking for external contributions feature request Ideas to improve an integration P2
Projects
Development

No branches or pull requests

3 participants