Boto3 bedrock.list_guardrails() failing if passing the retrieved nextToken among with a guardrail_id #4389
Labels
bedrock
bug
This issue is a confirmed bug.
p2
This is a standard priority issue
pagination
service-api
This issue is caused by the service API, not the SDK implementation.
Describe the bug
Bedrock ListGuardrails API fails on pagination
Description
When attempting to paginate through guardrails using the Bedrock
list_guardrails
API, the second API call fails when passing the receivednextToken
. The first call succeeds and returns anextToken
, but using this token in a subsequent request results in an error. Notice that the very same code, invoked without passing the guardrailIdentifier is working correctly.Current Code
First call succeeds
response = bedrock.list_guardrails( guardrailIdentifier=guardrail_id, maxResults=100, )
Second call fails when using the nextToken from the first response
response = bedrock.list_guardrails( guardrailIdentifier=guardrail_id, maxResults=100, nextToken=next_token # Token received from previous response )
Regression Issue
Expected Behavior
second invocation should retrieve correctly the guardrails versions.
Current Behavior
Second invocation of API, passing the nextToken just retrieved, result in error:
Error
An error occurred (InternalServerException) when calling the ListGuardrails operation (reached max retries: 4): The system encountered an unexpected error during processing.
Reproduction Steps
`
def get_latest_guardrail_version(guardrail_id, guardrail_region):
try:
bedrock = boto3.client("bedrock", region_name=guardrail_region)
next_token = None
`
Possible Solution
No response
Additional Information/Context
No response
SDK version used
1.35.97
Environment details (OS name and version, etc.)
Python 3.9, Windows 11
The text was updated successfully, but these errors were encountered: