{"record":{"id":"9ccaa24b783d1516","repo":"pulumi/pulumi","slug":"querying-search-failed-w","errorCode":null,"errorMessage":"querying search failed: %w","messagePattern":"querying search failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/backend/httpstate/client/client.go","lineNumber":2667,"sourceCode":"\treturn fmt.Sprintf(\"/api/orgs/%s/search/resources\", url.PathEscape(orgName))\n}\n\nfunc getNaturalLanguageSearchPath(orgName string) string {\n\treturn fmt.Sprintf(\"/api/orgs/%s/search/resources/parse\", url.PathEscape(orgName))\n}\n\nfunc getPulumiOrgSearchPath(baseURL string, orgName string) string {\n\treturn fmt.Sprintf(\"%s/%s/resources\", baseURL, url.PathEscape(orgName))\n}\n\n// Pulumi Cloud Search Functions\nfunc (pc *Client) GetSearchQueryResults(\n\tctx context.Context, orgName string, queryParams *apitype.PulumiQueryRequest, baseURL string,\n) (*apitype.ResourceSearchResponse, error) {\n\tvar resp apitype.ResourceSearchResponse\n\terr := pc.restCall(ctx, http.MethodGet, getSearchPath(orgName), queryParams, nil, &resp)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"querying search failed: %w\", err)\n\t}\n\tresp.URL = fmt.Sprintf(\"%s?query=%s\", getPulumiOrgSearchPath(baseURL, orgName), url.QueryEscape(queryParams.Query))\n\treturn &resp, nil\n}\n\nfunc (pc *Client) GetNaturalLanguageQueryResults(\n\tctx context.Context, orgName string, queryString string,\n) (*apitype.PulumiQueryResponse, error) {\n\tvar resp apitype.PulumiQueryResponse\n\tqueryParamObject := apitype.PulumiQueryRequest{\n\t\tQuery: queryString,\n\t}\n\terr := pc.restCall(ctx, http.MethodGet, getNaturalLanguageSearchPath(orgName), queryParamObject, nil, &resp)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"querying search failed: %w\", err)\n\t}\n\treturn &resp, nil\n}","sourceCodeStart":2649,"sourceCodeEnd":2685,"githubUrl":"https://github.com/pulumi/pulumi/blob/793f7b2e160db4321fb7fb6b0607461e01cb251e/pkg/backend/httpstate/client/client.go#L2649-L2685","documentation":"Returned by Client.GetSearchQueryResults when a GET to /api/orgs/{org}/search/resources fails. It wraps the restCall error, so HTTP status failures, transport errors, or decode failures of ResourceSearchResponse all produce this message. Used by `pulumi query` and resource-search tooling.","triggerScenarios":"Calling GetSearchQueryResults(ctx, orgName, queryParams, baseURL) with an invalid org name, a malformed query expression (bad Pulumi Cloud query syntax), missing search permission on the token, or a network/decode failure.","commonSituations":"See trigger scenarios.","solutions":["Validate the query string syntax against the Pulumi Cloud resource search syntax and retry.","Confirm the org name is correct and the token/account has access to that org.","Re-authenticate or use a token with resource search scope if 401/403.","Check network/proxy and retry on transient 5xx errors."],"exampleFix":"// before\nres, err := client.GetSearchQueryResults(ctx, \"acme\", &apitype.PulumiQueryRequest{Query: `type:\"pulumi:pulumi:Stack AND state=update`}, baseURL)\n// after\nquery := `type:\"pulumi:pulumi:Stack\" state:update` // balanced quotes, valid syntax\nres, err := client.GetSearchQueryResults(ctx, \"acme\", &apitype.PulumiQueryRequest{Query: query}, baseURL)\nif err != nil {\n\treturn fmt.Errorf(\"verify query syntax and org access: %w\", err)\n}","handlingStrategy":"validation","validationCode":"if orgName == \"\" {\n\treturn errors.New(\"org name required for resource search\")\n}\nif strings.TrimSpace(queryParams.Query) == \"\" {\n\treturn errors.New(\"query string must be non-empty\")\n}","typeGuard":"func isNotFound(err error) bool {\n\tvar er *client.RequestError\n\treturn errors.As(err, &er) && er.Code == http.StatusNotFound\n}","tryCatchPattern":"res, err := pc.GetSearchQueryResults(ctx, org, q, baseURL)\nif err != nil {\n\tvar er *client.RequestError\n\tif errors.As(err, &er) && er.Code == http.StatusBadRequest {\n\t\treturn fmt.Errorf(\"invalid query syntax %q: %w\", q.Query, err)\n\t}\n\treturn err\n}","preventionTips":["Validate query syntax (balanced quotes, known fields) client-side before sending.","Escape org names consistently; they are path-escaped by the client.","Keep org names in config in sync after renames."],"tags":["pulumi-cloud","http-client","search","rest-api"],"backgroundTag":"api-request-failed","analyzedSha":"793f7b2e160db4321fb7fb6b0607461e01cb251e","analyzedAt":"2026-08-31T09:36:43.099Z","schemaVersion":2},"datasetVersion":"2026-09-01T08:17:40.651Z"}