Просмотр исходного кода

Fix to Bedrock ARN validation (#2538)

Fixes Bedrock ARN validation

Updates the Bedrock ARN regex to allow alphanumeric characters, dots, hyphens, and colons in the resource ID.

This prevents validation errors when using ARNs containing those characters.
vagadiya 8 месяцев назад
Родитель
Сommit
294b52ef6a
2 измененных файлов с 2 добавлено и 2 удалено
  1. 1 1
      src/api/providers/bedrock.ts
  2. 1 1
      webview-ui/src/utils/validate.ts

+ 1 - 1
src/api/providers/bedrock.ts

@@ -515,7 +515,7 @@ export class AwsBedrockHandler extends BaseProvider implements SingleCompletionH
 		 * match[4] - The resource ID (e.g., "anthropic.claude-3-sonnet-20240229-v1:0")
 		 */
 
-		const arnRegex = /^arn:aws:bedrock:([^:]+):([^:]*):(?:([^\/]+)\/(.+)|([^\/]+))$/
+		const arnRegex = /^arn:aws:bedrock:([^:]+):([^:]*):(?:([^\/]+)\/([\w\.\-:]+)|([^\/]+))$/
 		let match = arn.match(arnRegex)
 
 		if (match && match[1] && match[3] && match[4]) {

+ 1 - 1
webview-ui/src/utils/validate.ts

@@ -89,7 +89,7 @@ export function validateApiConfiguration(apiConfiguration?: ApiConfiguration): s
  */
 export function validateBedrockArn(arn: string, region?: string) {
 	// Validate ARN format
-	const arnRegex = /^arn:aws:bedrock:([^:]+):(\d+):(foundation-model|provisioned-model|default-prompt-router)\/(.+)$/
+	const arnRegex = /^arn:aws:bedrock:([^:]+):([^:]*):(?:([^/]+)\/([\w.\-:]+)|([^/]+))$/
 	const match = arn.match(arnRegex)
 
 	if (!match) {