pulumi/pulumi · error
querying search failed: %w
Error message
querying search failed: %w
What it means
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.
Source
Thrown at pkg/backend/httpstate/client/client.go:2667
return fmt.Sprintf("/api/orgs/%s/search/resources", url.PathEscape(orgName))
}
func getNaturalLanguageSearchPath(orgName string) string {
return fmt.Sprintf("/api/orgs/%s/search/resources/parse", url.PathEscape(orgName))
}
func getPulumiOrgSearchPath(baseURL string, orgName string) string {
return fmt.Sprintf("%s/%s/resources", baseURL, url.PathEscape(orgName))
}
// Pulumi Cloud Search Functions
func (pc *Client) GetSearchQueryResults(
ctx context.Context, orgName string, queryParams *apitype.PulumiQueryRequest, baseURL string,
) (*apitype.ResourceSearchResponse, error) {
var resp apitype.ResourceSearchResponse
err := pc.restCall(ctx, http.MethodGet, getSearchPath(orgName), queryParams, nil, &resp)
if err != nil {
return nil, fmt.Errorf("querying search failed: %w", err)
}
resp.URL = fmt.Sprintf("%s?query=%s", getPulumiOrgSearchPath(baseURL, orgName), url.QueryEscape(queryParams.Query))
return &resp, nil
}
func (pc *Client) GetNaturalLanguageQueryResults(
ctx context.Context, orgName string, queryString string,
) (*apitype.PulumiQueryResponse, error) {
var resp apitype.PulumiQueryResponse
queryParamObject := apitype.PulumiQueryRequest{
Query: queryString,
}
err := pc.restCall(ctx, http.MethodGet, getNaturalLanguageSearchPath(orgName), queryParamObject, nil, &resp)
if err != nil {
return nil, fmt.Errorf("querying search failed: %w", err)
}
return &resp, nil
}View on GitHub (pinned to 793f7b2e16)
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.
Example fix
// before
res, err := client.GetSearchQueryResults(ctx, "acme", &apitype.PulumiQueryRequest{Query: `type:"pulumi:pulumi:Stack AND state=update`}, baseURL)
// after
query := `type:"pulumi:pulumi:Stack" state:update` // balanced quotes, valid syntax
res, err := client.GetSearchQueryResults(ctx, "acme", &apitype.PulumiQueryRequest{Query: query}, baseURL)
if err != nil {
return fmt.Errorf("verify query syntax and org access: %w", err)
} Defensive patterns
Strategy: validation
Validate before calling
if orgName == "" {
return errors.New("org name required for resource search")
}
if strings.TrimSpace(queryParams.Query) == "" {
return errors.New("query string must be non-empty")
} Type guard
func isNotFound(err error) bool {
var er *client.RequestError
return errors.As(err, &er) && er.Code == http.StatusNotFound
} Try / catch
res, err := pc.GetSearchQueryResults(ctx, org, q, baseURL)
if err != nil {
var er *client.RequestError
if errors.As(err, &er) && er.Code == http.StatusBadRequest {
return fmt.Errorf("invalid query syntax %q: %w", q.Query, err)
}
return err
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: See trigger scenarios.
Understand the failure class
Background: "API request failed": what wrapped HTTP errors from external APIs mean and how to find the real cause — this error's family across 29 libraries.
Related errors
- getting deployment %s failed: %w
- getting deployment by version %s failed: %w
- getting deployment %s updates failed: %w
- getting deployment %s logs failed: %w
- querying capabilities failed: %w
AI-assisted analysis of pulumi/pulumi@793f7b2e16 (2026-08-31).
Data as JSON: /api/errors/9ccaa24b783d1516.
Report an issue: GitHub.