Explorar el Código

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 hace 8 meses
padre
commit
294b52ef6a
Se han modificado 2 ficheros con 2 adiciones y 2 borrados
  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) {