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" #9027

Closed
ichino-kazuaki opened this issue May 11, 2024 · 4 comments
Labels
bedrock bug This issue is a bug. p2 This is a standard priority issue service-api This issue is due to a problem in a service API, not the SDK implementation.

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 This issue is a bug. needs-triage This issue or PR still needs to be triaged. 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 tim-finnigan self-assigned this May 13, 2024
@tim-finnigan tim-finnigan added the investigating This issue is being investigated and/or work is in progress to resolve the issue. label May 13, 2024
@tim-finnigan
Copy link
Contributor

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)

Update - transferring back to this repository for tracking going forward.

@tim-finnigan tim-finnigan added service-api This issue is due to a problem in a service API, not the SDK implementation. and removed investigating This issue is being investigated and/or work is in progress to resolve the issue. needs-triage This issue or PR still needs to be triaged. labels May 13, 2024
@tim-finnigan tim-finnigan transferred this issue from aws/aws-cli May 13, 2024
@tim-finnigan tim-finnigan transferred this issue from aws/aws-sdk Oct 30, 2024
@tim-finnigan tim-finnigan added the p2 This is a standard priority issue label Oct 30, 2024
@tim-finnigan tim-finnigan removed their assignment Oct 30, 2024
@tim-finnigan
Copy link
Contributor

We heard back from the Bedrock team who noted that the RetrieveAndGenerate model ARN regex now accepts ARNs such as the one referenced here.

Copy link

github-actions bot commented Dec 6, 2024

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

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 bug. p2 This is a standard priority issue service-api This issue is due to a problem in a service API, not the SDK implementation.
Projects
None yet
Development

No branches or pull requests

2 participants