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:
@@ -122,8 +122,14 @@ func (h *S3TablesHandler) handleListTableBuckets(w http.ResponseWriter, r *http.
|
|||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// If the directory doesn't exist, return empty list
|
// Check if it's a "not found" error - return empty list in that case
|
||||||
buckets = []TableBucketSummary{}
|
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{
|
resp := &ListTableBucketsResponse{
|
||||||
|
|||||||
Reference in New Issue
Block a user