{"record":{"id":"e5f6c0cbf3c8348f","repo":"googleapis/mcp-toolbox","slug":"executepipeline-api-error-status-d-s","errorCode":null,"errorMessage":"executePipeline API error (status %d): %s","messagePattern":"executePipeline API error \\(status (.+?)\\): (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/firestore/firestore.go","lineNumber":936,"sourceCode":"\t}\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\treq.Header.Set(\"User-Agent\", userAgent)\n\treq.Header.Set(\"x-goog-request-params\", fmt.Sprintf(\"project_id=%s&database_id=%s\", s.GetProjectId(), s.GetDatabaseId()))\n\treq.Header.Set(\"x-goog-firestore-api-requester\", \"querydata\")\n\n\tresp, err := httpClient.Do(req)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to execute pipeline request: %w\", err)\n\t}\n\tdefer resp.Body.Close()\n\n\trespBody, err := io.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to read response body: %w\", err)\n\t}\n\n\tif resp.StatusCode < 200 || resp.StatusCode >= 300 {\n\t\treturn nil, fmt.Errorf(\"executePipeline API error (status %d): %s\", resp.StatusCode, string(respBody))\n\t}\n\n\tvar result any\n\tif err := json.Unmarshal(respBody, &result); err != nil {\n\t\treturn string(respBody), nil\n\t}\n\n\treturn result, nil\n}\n\nfunc initFirestoreConnection(\n\tctx context.Context,\n\ttracer trace.Tracer,\n\tname string,\n\tproject string,\n\tdatabase string,\n) (*firestore.Client, error) {\n\tctx, span := sources.InitConnectionSpan(ctx, tracer, SourceType, name)","sourceCodeStart":918,"sourceCodeEnd":954,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/firestore/firestore.go#L918-L954","documentation":"This error indicates the Firestore executePipeline REST API returned a non-2xx status code. The error message embeds both the numeric HTTP status and the raw response body, which for Google APIs is usually a JSON error object with a human-readable message explaining the failure (bad pipeline syntax, permission denied, missing index, etc.).","triggerScenarios":"resp.StatusCode < 200 || resp.StatusCode >= 300 after the executePipeline POST — e.g. 400 for a malformed MQL pipeline, 401/403 for bad or insufficient credentials, 404 for wrong project/database, 429 quota exceeded, 5xx server-side errors.","commonSituations":"Syntax errors in the MQL pipeline string; the service account lacking Firestore access or Firestore API not enabled on the project; querying a database id that doesn't exist; exceeding per-minute quotas; Google-side outages returning 500/503.","solutions":["Read the embedded response body in the error — Google's JSON error message pinpoints the exact problem (invalid argument, permission, not found)","Validate the MQL pipeline syntax (stage names, aggregate functions) — 400s are usually pipeline mistakes","Verify credentials/permissions: enable the Firestore API, grant the service account appropriate datastore roles","Check status 429/5xx and retry with exponential backoff"],"exampleFix":"// before\npipeline := \"{documents: {path: 'users`'}}\" // bad syntax\nres, _ := src.ExecuteMQL(ctx, pipeline)\n// after\npipeline := \"{documents: {path: 'users'}}\"\nres, err := src.ExecuteMQL(ctx, pipeline)\nif err != nil { log.Printf(\"executePipeline failed: %v\", err) } // body shows API reason","handlingStrategy":"try-catch","validationCode":"// validate before calling: credentials + API enabled\ncreds, err := google.FindDefaultCredentials(ctx)\nif err != nil { log.Fatal(\"no ADC: \", err) }","typeGuard":null,"tryCatchPattern":"res, err := src.ExecuteMQL(ctx, pipeline)\nif err != nil {\n    var apiErr struct {\n        Error struct{ Code int; Message string } `json:\"error\"`\n    }\n    if m := regexp.MustCompile(`status (\\d+)\\): (.*)$`).FindStringSubmatch(err.Error()); m != nil {\n        fmt.Sprintf // inspect m[1] status, m[2] body\n        _ = json.Unmarshal([]byte(m[2]), &apiErr)\n        log.Printf(\"API %d: %s\", apiErr.Error.Code, apiErr.Error.Message)\n    }\n}","preventionTips":["Always log the full error — the embedded body names the exact API problem","Retry only 429/5xx with exponential backoff; fix 400/403/404 manually","Validate MQL pipeline syntax and IAM permissions before deploying"],"tags":["firestore","http","api-error","status-code"],"backgroundTag":"api-error-response","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"}