Browse Source

s3tables: improve error handling specificity in ListTableBuckets

- Specifically check for 'not found' errors instead of catching all errors
- Return empty list only when directory doesn't exist
- Propagate other errors (network, permission) with context
- Prevents masking real errors
pull/8147/head
Chris Lu 5 days ago
parent
commit
450407fda1
  1. 10
      weed/s3api/s3tables/handler_bucket_get_list_delete.go

10
weed/s3api/s3tables/handler_bucket_get_list_delete.go

@ -122,8 +122,14 @@ func (h *S3TablesHandler) handleListTableBuckets(w http.ResponseWriter, r *http.
})
if err != nil {
// If the directory doesn't exist, return empty list
buckets = []TableBucketSummary{}
// Check if it's a "not found" error - return empty list in that case
if strings.Contains(err.Error(), "no entry is found") || strings.Contains(err.Error(), "not found") {
buckets = []TableBucketSummary{}
} else {
// For other errors, return error response
h.writeError(w, http.StatusInternalServerError, ErrCodeInternalError, fmt.Sprintf("failed to list table buckets: %v", err))
return err
}
}
resp := &ListTableBucketsResponse{

Loading…
Cancel
Save