{"record":{"id":"a6b5c910581ab870","repo":"googleapis/mcp-toolbox","slug":"failed-to-create-search-entries-iterator-for-proje","errorCode":null,"errorMessage":"failed to create search entries iterator for project %q","messagePattern":"failed to create search entries iterator for project %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/dataplex/dataplex.go","lineNumber":293,"sourceCode":"\nfunc (s *Source) searchRequest(ctx context.Context, query string, pageSize int, orderBy string, scope string) (*dataplexapi.SearchEntriesResultIterator, error) {\n\t// Create SearchEntriesRequest with the provided parameters\n\treq := &dataplexpb.SearchEntriesRequest{\n\t\tQuery:          query,\n\t\tName:           fmt.Sprintf(\"projects/%s/locations/global\", s.ProjectID()),\n\t\tPageSize:       int32(pageSize),\n\t\tOrderBy:        orderBy,\n\t\tSemanticSearch: true,\n\t}\n\n\tif scope != \"\" {\n\t\treq.Scope = scope\n\t}\n\n\t// Perform the search using the CatalogClient - this will return an iterator\n\tit := s.CatalogClient().SearchEntries(ctx, req)\n\tif it == nil {\n\t\treturn nil, fmt.Errorf(\"failed to create search entries iterator for project %q\", s.ProjectID())\n\t}\n\treturn it, nil\n}\n\nfunc (s *Source) SearchAspectTypes(ctx context.Context, query string, pageSize int, orderBy string) ([]*dataplexpb.AspectType, error) {\n\tif pageSize <= 0 {\n\t\treturn nil, fmt.Errorf(\"pageSize must be positive: %d\", pageSize)\n\t}\n\tq := query + \" type=projects/dataplex-types/locations/global/entryTypes/aspecttype\"\n\tit, err := s.searchRequest(ctx, q, pageSize, orderBy, \"\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Iterate through the search results and call GetAspectType for each result using the resource name\n\tvar results []*dataplexpb.AspectType\n\tfor len(results) < pageSize {\n\t\tentry, err := it.Next()","sourceCodeStart":275,"sourceCodeEnd":311,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/dataplex/dataplex.go#L275-L311","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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)."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"// before invoking search tools\nif src.SourceType() != dataplex.SourceType {\n\treturn fmt.Errorf(\"source is not dataplex\")\n}\n// ensure initialization succeeded and client is non-nil\n_, err := projectsClient.GetProject(ctx, &resourcemanagerpb.GetProjectRequest{Name: \"projects/\" + projectID})","typeGuard":"func hasDataplexClient(s *dataplex.Source) bool {\n\treturn s != nil && s.CatalogClient() != nil\n}","tryCatchPattern":"entries, err := src.SearchEntries(ctx, query, pageSize, orderBy, aspectTypes)\nif err != nil {\n\tif strings.Contains(err.Error(), \"failed to create search entries iterator\") {\n\t\tlog.Printf(\"Dataplex client unavailable; reinitializing source: %v\", err)\n\t\treturn reinitializeSourceAndRetry(ctx)\n\t}\n\treturn err\n}","preventionTips":["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."],"tags":["gcp","dataplex","search","iterator","nil-client"],"backgroundTag":"nil-client-iterator","analyzedSha":"8cc6e09de2ad7b8bffc77751799585a1401a48eb","analyzedAt":"2026-09-05T01:10:36.887Z","contentChangedAt":"2026-09-05T01:10:36.887Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}