Repository navigation
fix(vectorize): support session tokens and default AWS credential chain in BedrockVectorizer - #865
pcbeingused333 wants to merge 6 commits into
Conversation
…in in BedrockVectorizer BedrockVectorizer required static aws_access_key_id/aws_secret_access_key and never forwarded a session token, so temporary (STS/SSO) and IAM-role credentials failed. Forward aws_session_token (api_config or AWS_SESSION_TOKEN) and fall back to boto3's default credential chain when no static keys are given.
|
Pushed a follow-up commit (62ab031): This comment was drafted with Claude Code. |
…-credentials errors - Do not copy AWS_* environment credentials into client kwargs; boto3 resolves them itself and keeps refresh support. - Reject an explicit aws_session_token without access key and secret. - Reject conflicting credential values between api_config and kwargs; keep forwarding unrelated boto3 options. - Propagate NoCredentialsError without retries or ValueError wrapping.
|
Thanks for the detailed review. Pushed a follow-up commit addressing all four points:
Unit tests cover each case. This comment was drafted with Claude Code. |
Treat SSOTokenLoadError like NoCredentialsError in the constructor, embed and embed_many paths, and skip the botocore-dependent tests when the SDK is not installed. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Thanks, both points are addressed in follow-up commits:
Expired-token errors ( This comment was drafted with Claude Code. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
Reviewed by Cursor Bugbot for commit 471bd32. Configure here.
vishal-bala
left a comment
There was a problem hiding this comment.
Thanks for addressing the missing-login case and the optional SDK tests. I’m keeping changes requested for the expired SSO login case in the linked thread. Once the constructor surfaces the SDK’s login error on the first attempt for both SSO profile formats, I’m comfortable approving. Bugbot thread

Motivation
BedrockVectorizeronly readaws_access_key_id/aws_secret_access_keyand raisedValueErrorwhen either was missing. It never forwardedaws_session_token, so temporary (STS) credentials were rejected by AWS, and SSO profiles, IAM roles and container/instance credentials could not be used at all because boto3's default credential chain was never reached.Changes
Session token and default credential chain
_initialize_clientnow also readsaws_session_token(fromapi_configorAWS_SESSION_TOKEN) and forwards it together with the static keys. When neither static key is set, no credential arguments are passed toboto3.client, so boto3's default chain (SSO, IAM role, shared profile, container/instance credentials) applies. Supplying only one of the two keys raises aValueErrorthat names both. Extra**kwargsstill reachboto3.client.ValueError.tests/unit/test_bedrock_vectorizer.pywith a mockedboto3(no network).Release Notes
BedrockVectorizeracceptsaws_session_token(orAWS_SESSION_TOKEN) and, when no static keys are given, uses boto3's default credential chain instead of raisingValueError.AI Assistance
Claude Code: implementation, tests and description.
Reviewer Brief
Start here:
redisvl/utils/vectorize/bedrock.py,_initialize_client(). It decides which credential arguments reachboto3.client.Where it could fail
redisvl/utils/vectorize/bedrock.py, retry rule:TypeErrorand the credential and SSO login errors skip retries; since5a9ec15this includesUnauthorizedSSOTokenErrorandTokenRetrievalErrorfor expired SSO logins, also from the constructor's dimension check (two regression cases using botocore credential resolution).Not verified: the live AWS Bedrock service, real SSO/IAM-role sessions; the full unit suite (this test file was run with
--noconftest, since the repo conftest starts a Docker Redis it doesn't need).Beyond CI: 12 of the 14 tests fail on
45a5df4and all pass on this branch. With botocore 1.44.10, an SSO profile with no cached token raisesSSOTokenLoadErrorfrom the constructor, and partial credentials (environment or shared files) raisePartialCredentialsErrorfromboto3.clientitself; a failed refresh of expiring environment credentials raises it from the embed call, unwrapped.Since the last brief: explicit credentials are validated (token without keys, conflicting values), environment credentials are left to boto3, and missing or partial credentials and missing SSO login surface without retries.
Reviewed
471bd32· Claude Code (claude-sonnet-5-5) · lenses: correctness, tests, docsNote
Medium Risk
Touches AWS authentication and client initialization for all Bedrock embeddings; behavior changes when only env/SSO credentials are used and when auth fails mid-call, though coverage is strong in new unit tests.
Overview
BedrockVectorizer no longer requires static access keys up front. Explicit credentials now support
aws_session_token(fromapi_configor constructor kwargs), with validation for partial key pairs, session token without keys, and conflictingapi_configvs kwargs. When callers pass no explicit keys, credential env vars are not copied intoboto3.clientso botocore can use its default chain and refresh (SSO, IAM roles, etc.); onlyregion_nameand other kwargs are forwarded.Embed paths switch Tenacity to
_is_retryable, which skips retries onTypeErrorand several botocore credential/SSO errors (NoCredentialsError,PartialCredentialsError,SSOTokenLoadError,TokenRetrievalError,UnauthorizedSSOTokenError). Those exceptions are re-raised from_set_model_dims,_embed, and_embed_manyinstead of being wrapped as genericValueErrors or retried up to six times.Adds
tests/unit/test_bedrock_vectorizer.pycovering token forwarding, default chain, validation, credential error surfacing from construction and embed calls, and expired SSO profiles (no live AWS).Reviewed by Cursor Bugbot for commit 5a9ec15. Bugbot is set up for automated code reviews on this repo. Configure here.