Skip to content

Commit da8a2f7

Browse files
authored
fix(mcp): normalize paginateAll empty results to non-nil slice
1 parent bdafd80 commit da8a2f7

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

internal/mcp/pagination.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ func paginateAll[T any](
8080
if err != nil {
8181
return nil, fmt.Errorf("list%s: backend serverID=%s: %w", itemKind, serverID, err)
8282
}
83+
if result == nil {
84+
result = []T{}
85+
}
8386
logConn.Printf("list%s: received %d %s total from serverID=%s", itemKind, len(result), itemKind, serverID)
8487
return result, nil
8588
}

internal/mcp/pagination_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ func TestPaginateAllHelper(t *testing.T) {
246246
items, err := paginateAll("server1", "Tools", fetch)
247247

248248
require.NoError(t, err)
249+
assert.NotNil(t, items)
249250
assert.Empty(t, items)
250251
})
251252

0 commit comments

Comments
 (0)