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: improve error handling and permission logic

Chris Lu1c0d37e15a9f
diff --git a/weed/s3api/s3tables/handler_namespace.go b/weed/s3api/s3tables/handler_namespace.go
index 9634bc29dc..6d54b86e04 100644
--- a/weed/s3api/s3tables/handler_namespace.go
+++ b/weed/s3api/s3tables/handler_namespace.go
@@ -167,7 +167,11 @@ func (h *S3TablesHandler) handleGetNamespace(w http.ResponseWriter, r *http.Requ
})
if err != nil {
- h.writeError(w, http.StatusNotFound, ErrCodeNoSuchNamespace, fmt.Sprintf("namespace %s not found", flattenNamespace(req.Namespace)))
+ if errors.Is(err, filer_pb.ErrNotFound) {
+ h.writeError(w, http.StatusNotFound, ErrCodeNoSuchNamespace, fmt.Sprintf("namespace %s not found", flattenNamespace(req.Namespace)))
+ } else {
+ h.writeError(w, http.StatusInternalServerError, ErrCodeInternalError, fmt.Sprintf("failed to get namespace: %v", err))
+ }
return err
}
diff --git a/weed/s3api/s3tables/permissions.go b/weed/s3api/s3tables/permissions.go
index 5d3da336ee..5fc04f8035 100644
--- a/weed/s3api/s3tables/permissions.go
+++ b/weed/s3api/s3tables/permissions.go
@@ -159,8 +159,7 @@ func CanListTables(principal, owner string) bool {
// CanManagePolicy checks if principal can manage policies
func CanManagePolicy(principal, owner string) bool {
- // Policy management requires owner permissions
- return principal == owner
+ return CheckPermission("ManagePolicy", principal, owner)
}
// CanManageTags checks if principal can manage tags