aws-samples / aws-samples/amazon-bedrock-samples

BUG? - prompt_flow_kb_rag_example notebook - Creating aws-overview-kb fails with ValidationException - name too long

Open
#582 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Jupyter Notebook
Stars
1.5k
Forks
734
Avg merge
1d 6h
Merged PRs (30d)
4

Description

I'm not sure how to fix the call to create the KB so the name isn't too long. The name passed is <32 chars but somehow on Step 3 it doubles the name.

```
print(KB_NAME_1)
print(KB_DESC_1)
```
aws-overview-kb
Use this KB to retrieve information about AWS services that the user is asking about.

```
%%time
try:
generic_aws_kb_id, generic_aws_ds_id = kb.create_or_retrieve_knowledge_base(
KB_NAME_1,
KB_DESC_1,
FOUNDATIONAL_S3_INPUT_BUCKET,
)
logger.info(f"Knowledge Base ID: {generic_aws_kb_id}")
logger.info(f"Data Source ID: {generic_aws_ds_id}")
except Exception as e:
logger.error(f"An error occurred while creating the KB: {e}")
```

Creating KB aws-overview-kb

Step 1 - Creating or retrieving 'my-bucket' S3 bucket for Knowledge Base documents
Bucket 'my-bucket' already exists - retrieving it!

Step 2 - Creating Knowledge Base Execution Role (AmazonBedrockExecutionRoleForKnowledgeBase_aws-overview-kb) and Policies
AmazonBedrockFoundationModelPolicyForKnowledgeBase_aws-overview-kb already exists, retrieving it!
AmazonBedrockS3PolicyForKnowledgeBase_aws-overview-kb already exists, retrieving it!
AmazonBedrockExecutionRoleForKnowledgeBase_aws-overview-kb already exists, retrieving it!

Step 3 - Creating OSS encryption, network and data access policies

[2025-05-14 19:19:21,807] p2079 {:10} ERROR - An error occurred while creating the KB: An error occurred (ValidationException) when calling the CreateSecurityPolicy operation: 1 validation error detected: Value 'aws-overview-kb-sp-aws-overview-kb' at 'name' failed to satisfy constraint: Member must have length less than or equal to 32

CPU times: user 66.7 ms, sys: 1.29 ms, total: 67.9 ms
Wall time: 1.67 s

Contributor guide

Open the contributing guide

Research direction

Open the prompt_flow_kb_rag_example notebook and trace the kb.create_or_retrieve_knowledge_base call through Step 3, where CreateSecurityPolicy fails. Inspect the generated security-policy name and related naming logic; done means the example creates or retrieves the knowledge base without exceeding AWS's 32-character name limit.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, jupyter-notebook, python
Domain
ai, cloud
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.