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
This commit is contained in:
Chris Lu
2026-01-28 01:14:14 -08:00
parent b09d4d5d69
commit 450407fda1

View File

@@ -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{