-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
Describe the bug
I am trying to delete a Bedrock knowledge base using Python SDK (Boto3)
client.delete_knowledge_base(knowledgeBaseId=kb_id)
When the provided kb_id does not follow the required format (I assume it should be ^[A-Z0-9]{10}$), for example, when I provide Knowledge Base name instead of Knowledge Base ID or when passing E94N4QO8 (8 characters), then it raises an irrelevant error:
botocore.errorfactory.AccessDeniedException:
An error occurred (AccessDeniedException) when calling the DeleteKnowledgeBase operation:
User: arn:aws:iam::?????:user/????? is not authorized to perform: bedrock:DeleteKnowledgeBase
The error is misleading because the user has permission for bedrock:DeleteKnowledgeBase.
My expected behaviour is to either validate the format of knowledgeBaseId and raise a validation error, or at least a ResourceNotFoundException
Regression Issue
- Select this option if this issue appears to be a regression.
Expected Behavior
My expected behaviour is to either validate the format of knowledgeBaseId and raise a validation error, or at least a ResourceNotFoundException
Current Behavior
It raises botocore.errorfactory.AccessDeniedException
Reproduction Steps
client = session.client('bedrock-agent')
kb_id = 'E94N4QO8'
client.delete_knowledge_base(knowledgeBaseId=kb_id)
Possible Solution
Validate the provided argument and raise a relevant error
Additional Information/Context
No response
SDK version used
1.39.11
Environment details (OS name and version, etc.)
Windows 11 24H2, Python 3.11.3, VS Code