Browse Source

feat: aws support forbidden map (#379)

zijiren 3 months ago
parent
commit
5a695fdd9a
1 changed files with 9 additions and 1 deletions
  1. 9 1
      core/relay/adaptor/aws/claude/error.go

+ 9 - 1
core/relay/adaptor/aws/claude/error.go

@@ -3,6 +3,7 @@ package aws
 import (
 	"errors"
 	"net/http"
+	"strings"
 
 	awshttp "github.com/aws/aws-sdk-go-v2/aws/transport/http"
 	"github.com/aws/smithy-go"
@@ -23,5 +24,12 @@ func UnwrapInvokeError(err error) (int, string) {
 		return http.StatusInternalServerError, err.Error()
 	}
 
-	return awshttpErr.HTTPStatusCode(), awshttpErr.Err.Error()
+	code := awshttpErr.HTTPStatusCode()
+	message := awshttpErr.Err.Error()
+
+	if strings.Contains(message, "Operation not allowed") {
+		code = http.StatusForbidden
+	}
+
+	return code, message
 }