googleapis/mcp-toolbox · error
failed to create search entries iterator for project %q
Error message
failed to create search entries iterator for project %q
What it means
searchRequest builds a SearchEntries request on the Dataplex Catalog client and calls CatalogClient().SearchEntries, which returns a search iterator. This error is returned when the iterator is nil, i.e. the client could not produce a streaming search iterator for the given request/scope. Note it does not wrap an underlying error — it is a nil-guard on the returned iterator.
Source
Thrown at internal/sources/dataplex/dataplex.go:293
func (s *Source) searchRequest(ctx context.Context, query string, pageSize int, orderBy string, scope string) (*dataplexapi.SearchEntriesResultIterator, error) {
// Create SearchEntriesRequest with the provided parameters
req := &dataplexpb.SearchEntriesRequest{
Query: query,
Name: fmt.Sprintf("projects/%s/locations/global", s.ProjectID()),
PageSize: int32(pageSize),
OrderBy: orderBy,
SemanticSearch: true,
}
if scope != "" {
req.Scope = scope
}
// Perform the search using the CatalogClient - this will return an iterator
it := s.CatalogClient().SearchEntries(ctx, req)
if it == nil {
return nil, fmt.Errorf("failed to create search entries iterator for project %q", s.ProjectID())
}
return it, nil
}
func (s *Source) SearchAspectTypes(ctx context.Context, query string, pageSize int, orderBy string) ([]*dataplexpb.AspectType, error) {
if pageSize <= 0 {
return nil, fmt.Errorf("pageSize must be positive: %d", pageSize)
}
q := query + " type=projects/dataplex-types/locations/global/entryTypes/aspecttype"
it, err := s.searchRequest(ctx, q, pageSize, orderBy, "")
if err != nil {
return nil, err
}
// Iterate through the search results and call GetAspectType for each result using the resource name
var results []*dataplexpb.AspectType
for len(results) < pageSize {
entry, err := it.Next()View on GitHub (pinned to 8cc6e09de2)
Solutions
- Restart the toolbox so the Dataplex source is re-initialized and the Catalog client is rebuilt.
- Confirm the dataplex source initialized successfully at startup (no earlier init errors were swallowed).
- Update cloud.google.com/go/dataplex and check its SearchEntries behavior — a nil iterator without error indicates a client-side issue, worth reporting upstream.
- Validate the query, scope, and project configuration in the tool config (e.g. project matches an existing, enabled Dataplex project).
Defensive patterns
Strategy: type-guard
Validate before calling
// before invoking search tools
if src.SourceType() != dataplex.SourceType {
return fmt.Errorf("source is not dataplex")
}
// ensure initialization succeeded and client is non-nil
_, err := projectsClient.GetProject(ctx, &resourcemanagerpb.GetProjectRequest{Name: "projects/" + projectID}) Type guard
func hasDataplexClient(s *dataplex.Source) bool {
return s != nil && s.CatalogClient() != nil
} Try / catch
entries, err := src.SearchEntries(ctx, query, pageSize, orderBy, aspectTypes)
if err != nil {
if strings.Contains(err.Error(), "failed to create search entries iterator") {
log.Printf("Dataplex client unavailable; reinitializing source: %v", err)
return reinitializeSourceAndRetry(ctx)
}
return err
} Prevention
- Never invoke search tools on a source whose Initialize failed or was closed.
- Restart the toolbox if the Dataplex client was torn down mid-run.
- Keep cloud.google.com/go/dataplex current; nil iterators without error indicate client-side bugs worth reporting.
- Validate the project config so scopes/queries are well-formed before search.
When it happens
Trigger: searchRequest (called by SearchAspectTypes and SearchEntries) invokes s.CatalogClient().SearchEntries(ctx, req) and receives a nil iterator — typically because the Catalog client is nil/uninitialized (source closed or misconstructed) rather than a query problem.
Common situations: Invoking tools after the source's client was closed; a library update where SearchEntries error handling changed; constructing a Source outside Initialize with a nil Client; project/scope strings so malformed that the client short-circuits.
Related errors
- dataplex catalog client is nil
- failed to create search entries iterator
- 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/a6b5c910581ab870.
Report an issue: GitHub.