From 090d4738226d0e3ded44db0caadd144733565622 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Wed, 28 Jan 2026 13:38:41 -0800 Subject: [PATCH] s3tables: allow hyphens in namespace and table names Relaxed regex validation in utils.go to support hyphens in S3 Tables namespaces and table names, improving consistency with S3 bucket naming and allowing derived names from services like S3 Storage Lens. --- weed/s3api/s3tables/utils.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/weed/s3api/s3tables/utils.go b/weed/s3api/s3tables/utils.go index 994446330..a557c09cf 100644 --- a/weed/s3api/s3tables/utils.go +++ b/weed/s3api/s3tables/utils.go @@ -13,7 +13,7 @@ import ( var ( bucketARNPattern = regexp.MustCompile(`^arn:aws:s3tables:[^:]*:[^:]*:bucket/([a-z0-9_-]+)$`) - tableARNPattern = regexp.MustCompile(`^arn:aws:s3tables:[^:]*:[^:]*:bucket/([a-z0-9_-]+)/table/([a-z0-9_]+)/([a-z0-9_]+)$`) + tableARNPattern = regexp.MustCompile(`^arn:aws:s3tables:[^:]*:[^:]*:bucket/([a-z0-9_-]+)/table/([a-z0-9_-]+)/([a-z0-9_-]+)$`) bucketNamePattern = regexp.MustCompile(`^[a-z0-9_-]+$`) ) @@ -146,10 +146,10 @@ func validateNamespace(namespace []string) (string, error) { // Enforce allowed character set consistent with table naming. for _, ch := range name { - if (ch >= 'a' && ch <= 'z') || (ch >= '0' && ch <= '9') || ch == '_' { + if (ch >= 'a' && ch <= 'z') || (ch >= '0' && ch <= '9') || ch == '_' || ch == '-' { continue } - return "", fmt.Errorf("invalid namespace name: only 'a-z', '0-9', and '_' are allowed") + return "", fmt.Errorf("invalid namespace name: only 'a-z', '0-9', '_', and '-' are allowed") } return name, nil @@ -164,10 +164,10 @@ func validateTableName(name string) (string, error) { return "", fmt.Errorf("invalid table name: cannot be '.', '..' or contain '/'") } for _, ch := range name { - if (ch >= 'a' && ch <= 'z') || (ch >= '0' && ch <= '9') || ch == '_' { + if (ch >= 'a' && ch <= 'z') || (ch >= '0' && ch <= '9') || ch == '_' || ch == '-' { continue } - return "", fmt.Errorf("invalid table name: only 'a-z', '0-9', and '_' are allowed") + return "", fmt.Errorf("invalid table name: only 'a-z', '0-9', '_', and '-' are allowed") } return name, nil }