Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

s3tables: refactor bucket name validation into single function

Chris Lud5ce6a4cda02
diff --git a/weed/s3api/s3tables/utils.go b/weed/s3api/s3tables/utils.go
index d5c2ee9687..fa60a9421d 100644
--- a/weed/s3api/s3tables/utils.go
+++ b/weed/s3api/s3tables/utils.go
@@ -47,6 +47,12 @@ func parseTableFromARN(arn string) (bucketName, namespace, tableName string, err
return "", "", "", fmt.Errorf("invalid table ARN: %s", arn)
}
+ // Validate bucket name
+ bucketName = matches[1]
+ if err := validateBucketName(bucketName); err != nil {
+ return "", "", "", fmt.Errorf("invalid bucket name in ARN: %v", err)
+ }
+
// Namespace is already constrained by the regex; validate it directly.
namespace = matches[2]
_, err = validateNamespace([]string{namespace})
@@ -62,7 +68,7 @@ func parseTableFromARN(arn string) (bucketName, namespace, tableName string, err
if _, err := validateTableName(tableNameUnescaped); err != nil {
return "", "", "", fmt.Errorf("invalid table name in ARN: %v", err)
}
- return matches[1], namespace, tableNameUnescaped, nil
+ return bucketName, namespace, tableNameUnescaped, nil
}
// Path helpers