googleapis/mcp-toolbox · error
failed to create search entries iterator
Error message
failed to create search entries iterator
What it means
After the nil-client guard, ExecuteSearch calls client.SearchEntries(ctx, req) to get a result iterator. A nil iterator means the SDK could not begin the search (client in a bad state, invalid request such as empty query/pageSize conflicts). The function converts that condition into this explicit error instead of panicking on it.Next().
Source
Thrown at internal/sources/dataplex/searchcatalog/search_catalog.go:104
}
// ExtractType extracts the mapped type from a resource string based on a type map.
func ExtractType(resourceString string, typeMap map[string]string) string {
lastIndex := strings.LastIndex(resourceString, "/")
if lastIndex == -1 {
return resourceString
}
return typeMap[resourceString[lastIndex+1:]]
}
// ExecuteSearch performs the search and processes results.
func ExecuteSearch(ctx context.Context, client *dataplexapi.CatalogClient, req *dataplexpb.SearchEntriesRequest, typeMap map[string]string) ([]DataplexSearchResponse, error) {
if client == nil {
return nil, fmt.Errorf("dataplex catalog client is nil")
}
it := client.SearchEntries(ctx, req)
if it == nil {
return nil, fmt.Errorf("failed to create search entries iterator")
}
var results []DataplexSearchResponse
for req.PageSize <= 0 || len(results) < int(req.PageSize) {
entry, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
return nil, err
}
entrySource := entry.DataplexEntry.GetEntrySource()
resp := DataplexSearchResponse{
DisplayName: entrySource.GetDisplayName(),
Description: entrySource.GetDescription(),
Type: ExtractType(entry.DataplexEntry.GetEntryType(), typeMap),
Resource: entrySource.GetResource(),View on GitHub (pinned to 8cc6e09de2)
Solutions
- Log/inspect the constructed query from ConstructSearchQuery and ensure it is non-empty
- Ensure pageSize is a sane positive value and request fields are populated
- Re-create the CatalogClient with correct project/region and credentials
- Upgrade the dataplex Go SDK to the latest version
Example fix
// before
query := ConstructSearchQuery(prompt, nil, nil, nil, systemName) // may be empty
// after
if prompt == "" && len(projectIds) == 0 && len(parentIds) == 0 {
return nil, errors.New("search requires a prompt or project/parent filter")
}
query := ConstructSearchQuery(prompt, projectIds, parentIds, types, systemName) Defensive patterns
Strategy: validation
Validate before calling
if req.Query == "" { return errors.New("search query must not be empty") }
if req.PageSize < 0 { return errors.New("pageSize must be non-negative") } Try / catch
res, err := searchcatalog.ExecuteSearch(ctx, client, req, typeMap)
if err != nil {
if strings.Contains(err.Error(), "failed to create search entries iterator") {
// inspect req/req.Query and retry with corrected request
}
return err
} Prevention
- Ensure ConstructSearchQuery produces a non-empty query
- Sanity-check SearchEntriesRequest fields before executing
- Keep the dataplex SDK up to date
When it happens
Trigger: Calling the search_catalog tool with a CatalogClient whose SearchEntries returns nil — typically due to an invalid SearchEntriesRequest (empty query, malformed scope) or a degraded client.
Common situations: Prompt produced an empty query string after ConstructSearchQuery; projectIds/parentIds/types filtered everything out; SDK version mismatch where SearchEntries short-circuits on invalid input.
Related errors
- failed to create search entries iterator for project %q
- dataplex catalog client is nil
- failed to initialize dataplex client: %w
- failed to create Dataplex client for project %q: %w
- failed to get dataplex client: %w
AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05).
Data as JSON: /api/errors/fb81d002b147d013.
Report an issue: GitHub.