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

There is a pattern where ARN validation error occurs in aws bedrock-agent-runtime retrieve-and-generate" #744

Open
ichino-kazuaki opened this issue May 11, 2024 · 2 comments
Assignees
Labels
bedrock bug Something isn't working service-api This issue pertains to the AWS API

Comments

@ichino-kazuaki
Copy link

Describe the bug

The model ARN that can be retrieved with aws bedrock list-foundation-models, for example, for claude-3-sonnet, arn:aws:bedrock:us-west-2::foundation-model/anthropic.claude-3 -sonnet-20240229-v1:0 and arn:aws:bedrock:us-west-2::foundation-model/anthropic.claude-3-sonnet-20240229-v1:0:28k.
At this time, when specifying arn:aws:bedrock:us-west-2::foundation-model/anthropic.claude-3-sonnet-20240229-v1:0:28k, "1 validation error detected" occurred."

Expected Behavior

It is desirable to extend the validation judgment to allow ARNs with patterns such as ":28k" where the colon + character increases by one more step at the end.

Current Behavior

An error occurred (ValidationException) when calling the RetrieveAndGenerate operation: 1 validation error detected: Value 'arn:aws:bedrock:us-west-2::foundation-model/anthropic.claude-3-sonnet-20240229-v1:0:28k' at 'retrieveAndGenerateConfiguration.knowledgeBaseConfiguration.modelArn' failed to satisfy constraint: Member must satisfy regular expression pattern: (arn:aws(-[^:]+)?:bedrock:[a-z0-9-]{1,20}:(([0-9]{12}:custom-model/[a-z0-9-]{1,63}[.]{1}[a-z0-9-]{1,63}/[a-z0-9]{12})|(:foundation-model/[a-z0-9-]{1,63}[.]{1}[a-z0-9-]{1,63}([.:]?[a-z0-9-]{1,63}))|([0-9]{12}:provisioned-model/[a-z0-9]{12})))|([a-z0-9-]{1,63}[.]{1}[a-z0-9-]{1,63}([.:]?[a-z0-9-]{1,63}))|(([0-9a-zA-Z][_-]?)+)

Reproduction Steps

KNOWLEDGE_BASE_ID=XXXXXXXX
ARN="arn:aws:bedrock:us-west-2::foundation-model/anthropic.claude-3-sonnet-20240229-v1:0:28k"
TEXT="string you want to search for"
aws bedrock-agent-runtime retrieve-and-generate \
  --retrieve-and-generate-configuration type=KNOWLEDGE_BASE,knowledgeBaseConfiguration="{knowledgeBaseId=$KNOWLEDGE_BASE_ID,modelArn=$ARN}" --input text="$TEXT"

Possible Solution

No response

Additional Information/Context

No response

CLI version used

aws-cli/2.15.44 Python/3.11.8 Linux/6.1.87-99.174.amzn2023.x86_64 exec-env/CloudShell exe/x86_64.amzn.2023 prompt/off

Environment details (OS name and version, etc.)

Amazon Linux 2023

@ichino-kazuaki ichino-kazuaki added bug Something isn't working needs-triage labels May 11, 2024
@ichino-kazuaki
Copy link
Author

I think the problem is that the ARN string contains a : (colon) in the part corresponding to resource-id.
In this case, he discovered the presence of a problematic ARN format in a Bedrock model and created an issue with the aws bedrock-agent-runtime retrieve-and-generate subcommand.
If a similar ARN format exists for other AWS services, it is likely that this issue could equally occur.

@tim-finnigan
Copy link

tim-finnigan commented May 13, 2024

Thanks for reporting this issue. The Bedrock team owns the underlying ListFoundationModels and RetrieveAndGenerate APIs, and it appears that they are applying different input validation for modelArn in these APIs.

I will transfer this issue to our cross-SDK repository (since APIs like these are used across SDKs in addition to the AWS CLI) and reach out to the Bedrock team for review. I'll share any updates here in this issue. (ref: P129745717)

@tim-finnigan tim-finnigan added service-api This issue pertains to the AWS API and removed investigating needs-triage labels May 13, 2024
@tim-finnigan tim-finnigan transferred this issue from aws/aws-cli May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bedrock bug Something isn't working service-api This issue pertains to the AWS API
Projects
None yet
Development

No branches or pull requests

2 participants