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 pagination robustness and error handling in table listing handlers

Chris Lu0d65daad4c00
diff --git a/weed/s3api/s3tables/handler_table.go b/weed/s3api/s3tables/handler_table.go
index 98f7fab912..996eb02506 100644
--- a/weed/s3api/s3tables/handler_table.go
+++ b/weed/s3api/s3tables/handler_table.go
@@ -337,7 +337,9 @@ func (h *S3TablesHandler) handleListTables(w http.ResponseWriter, r *http.Reques
if err != nil {
if errors.Is(err, filer_pb.ErrNotFound) {
- h.writeError(w, http.StatusNotFound, ErrCodeNoSuchBucket, "resource not found")
+ // If the bucket or namespace directory is not found, return an empty result
+ tables = []TableSummary{}
+ paginationToken = ""
} else {
var authErr *AuthError
if errors.As(err, &authErr) {
@@ -345,8 +347,8 @@ func (h *S3TablesHandler) handleListTables(w http.ResponseWriter, r *http.Reques
} else {
h.writeError(w, http.StatusInternalServerError, ErrCodeInternalError, fmt.Sprintf("failed to list tables: %v", err))
}
+ return err
}
- return err
}
resp := &ListTablesResponse{
@@ -450,6 +452,9 @@ func (h *S3TablesHandler) listTablesWithClient(r *http.Request, client filer_pb.
}
}
+ if len(tables) < maxTables {
+ lastFileName = ""
+ }
return tables, lastFileName, nil
}
@@ -476,7 +481,7 @@ func (h *S3TablesHandler) listTablesInAllNamespaces(r *http.Request, client file
Directory: bucketPath,
Limit: 100,
StartFromFileName: lastNamespace,
- InclusiveStartFrom: lastNamespace == continuationNamespace && continuationNamespace != "" || lastNamespace == "",
+ InclusiveStartFrom: (lastNamespace == continuationNamespace && startTableName != "") || (lastNamespace == "" && continuationNamespace == ""),
})
if err != nil {
return nil, "", err