Skip to content
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

Boto3 bedrock.list_guardrails() failing if passing the retrieved nextToken among with a guardrail_id #4389

Closed
1 task
FraqMasq opened this issue Jan 13, 2025 · 2 comments
Assignees
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.

Comments

@FraqMasq
Copy link

FraqMasq commented Jan 13, 2025

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 received nextToken. The first call succeeds and returns a nextToken, 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

  • Select this option if this issue appears to be a regression.

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

    while True:
        if not next_token:
            response = bedrock.list_guardrails(
                guardrailIdentifier=guardrail_id,
                maxResults=10,
            )
        else:
            response = bedrock.list_guardrails(
                guardrailIdentifier=guardrail_id,
                maxResults=10,
                nextToken=next_token
            )

        next_token = response.get("nextToken")
        if not next_token:
            break

`

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

@FraqMasq FraqMasq added bug This issue is a confirmed bug. needs-triage This issue or PR still needs to be triaged. labels Jan 13, 2025
@RyanFitzSimmonsAK RyanFitzSimmonsAK self-assigned this Jan 13, 2025
@RyanFitzSimmonsAK RyanFitzSimmonsAK added bedrock investigating This issue is being investigated and/or work is in progress to resolve the issue. pagination p2 This is a standard priority issue and removed needs-triage This issue or PR still needs to be triaged. labels Jan 13, 2025
@RyanFitzSimmonsAK
Copy link
Contributor

Hi @FraqMasq, thanks for reaching out. The Bedrock service team is aware of this bug, and is working on a fix. I'll put any updates in this issue.

Ticket # for internal use : P155609965

@RyanFitzSimmonsAK RyanFitzSimmonsAK added service-api This issue is caused by the service API, not the SDK implementation. and removed investigating This issue is being investigated and/or work is in progress to resolve the issue. labels Jan 14, 2025
@RyanFitzSimmonsAK
Copy link
Contributor

This issue has been resolved by a fix from the service team. Thanks for reporting this, please feel free to re-open this issue if you're still having problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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.
Projects
None yet
Development

No branches or pull requests

2 participants