S3 Tables: fix gRPC stream loop handling for list operations

- Correctly handle io.EOF to terminate loops gracefully.
- Propagate other errors to prevent silent failures.
- Ensure all list results are processed effectively.
This commit is contained in:
Chris Lu
2026-01-28 12:09:04 -08:00
parent dc4c62e742
commit f13e250fc3
2 changed files with 18 additions and 4 deletions

View File

@@ -4,6 +4,7 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"io"
"net/http" "net/http"
"strings" "strings"
@@ -106,7 +107,10 @@ func (h *S3TablesHandler) handleListTableBuckets(w http.ResponseWriter, r *http.
for { for {
entry, respErr := resp.Recv() entry, respErr := resp.Recv()
if respErr != nil { if respErr != nil {
break if respErr == io.EOF {
break
}
return respErr
} }
if entry.Entry == nil { if entry.Entry == nil {
continue continue
@@ -219,7 +223,10 @@ func (h *S3TablesHandler) handleDeleteTableBucket(w http.ResponseWriter, r *http
for { for {
entry, err := resp.Recv() entry, err := resp.Recv()
if err != nil { if err != nil {
break if err == io.EOF {
break
}
return err
} }
if entry.Entry != nil && !strings.HasPrefix(entry.Entry.Name, ".") { if entry.Entry != nil && !strings.HasPrefix(entry.Entry.Name, ".") {
hasChildren = true hasChildren = true

View File

@@ -5,6 +5,7 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"io"
"net/http" "net/http"
"strings" "strings"
"time" "time"
@@ -338,7 +339,10 @@ func (h *S3TablesHandler) listTablesInNamespaceWithClient(ctx context.Context, c
for { for {
entry, respErr := resp.Recv() entry, respErr := resp.Recv()
if respErr != nil { if respErr != nil {
break if respErr == io.EOF {
break
}
return respErr
} }
if entry.Entry == nil { if entry.Entry == nil {
continue continue
@@ -415,7 +419,10 @@ func (h *S3TablesHandler) listTablesInAllNamespaces(ctx context.Context, filerCl
for { for {
entry, respErr := resp.Recv() entry, respErr := resp.Recv()
if respErr != nil { if respErr != nil {
break if respErr == io.EOF {
break
}
return respErr
} }
if entry.Entry == nil { if entry.Entry == nil {
continue continue