{"record":{"id":"27e016536698e478","repo":"googleapis/mcp-toolbox","slug":"failed-to-create-dataproc-batch-client-w","errorCode":null,"errorMessage":"failed to create dataproc batch client: %w","messagePattern":"failed to create dataproc batch client: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/serverlessspark/serverlessspark.go","lineNumber":75,"sourceCode":"\tName     string `yaml:\"name\" validate:\"required\"`\n\tType     string `yaml:\"type\" validate:\"required\"`\n\tProject  string `yaml:\"project\" validate:\"required\"`\n\tLocation string `yaml:\"location\" validate:\"required\"`\n}\n\nfunc (r Config) SourceConfigType() string {\n\treturn SourceType\n}\n\nfunc (r Config) Initialize(ctx context.Context, tracer trace.Tracer) (sources.Source, error) {\n\tua, err := util.UserAgentFromContext(ctx)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error in User Agent retrieval: %s\", err)\n\t}\n\tendpoint := fmt.Sprintf(\"%s-dataproc.googleapis.com:443\", r.Location)\n\tbatchClient, err := dataproc.NewBatchControllerClient(ctx, option.WithEndpoint(endpoint), option.WithUserAgent(ua))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create dataproc batch client: %w\", err)\n\t}\n\tsessionTemplateClient, err := dataproc.NewSessionTemplateControllerClient(ctx, option.WithEndpoint(endpoint), option.WithUserAgent(ua))\n\tif err != nil {\n\t\tbatchClient.Close()\n\t\treturn nil, fmt.Errorf(\"failed to create dataproc session template client: %w\", err)\n\t}\n\topsClient, err := longrunning.NewOperationsClient(ctx, option.WithEndpoint(endpoint), option.WithUserAgent(ua))\n\tif err != nil {\n\t\tbatchClient.Close()\n\t\tsessionTemplateClient.Close()\n\t\treturn nil, fmt.Errorf(\"failed to create longrunning client: %w\", err)\n\t}\n\tsessionClient, err := dataproc.NewSessionControllerClient(ctx, option.WithEndpoint(endpoint), option.WithUserAgent(ua))\n\tif err != nil {\n\t\tbatchClient.Close()\n\t\tsessionTemplateClient.Close()\n\t\topsClient.Close()\n\t\treturn nil, fmt.Errorf(\"failed to create dataproc session client: %w\", err)","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/serverlessspark/serverlessspark.go#L57-L93","documentation":"After resolving the regional endpoint, Initialize creates a Dataproc BatchControllerClient. Failure to construct this Google Cloud client (credential resolution, API enablement, endpoint problems) aborts source creation with this wrapped error. Google's client library returns the underlying cause, which is embedded in %w.","triggerScenarios":"dataproc.NewBatchControllerClient(ctx, option.WithEndpoint(<region>-dataproc.googleapis.com:443), option.WithUserAgent(ua)) fails — typically because Application Default Credentials cannot be resolved, the Dataproc API is disabled for the project, or the region string is invalid.","commonSituations":"GOOGLE_APPLICATION_CREDENTIALS unset or pointing to an invalid key file; no metadata server when running outside GCP without a service account key; `location` set to a bogus region producing a bad endpoint; Dataproc API not enabled; network/proxy blocking googleapis.com:443.","solutions":["Set up valid ADC: `gcloud auth application-default login` locally, or export GOOGLE_APPLICATION_CREDENTIALS to a service account key in non-GCP environments.","Enable the Dataproc API: `gcloud services enable dataproc.googleapis.com --project <project>`.","Verify `location` is a valid Dataproc region (e.g. us-central1); the endpoint is built as `<location>-dataproc.googleapis.com`.","Check outbound network access to `<region>-dataproc.googleapis.com:443` (proxies/firewalls).","Grant the identity `roles/dataproc.editor` (or similar) if errors indicate permission denial at request time."],"exampleFix":"// before — no credentials configured\nexport LOCATION=us-central1\n./toolbox\n// after\nexport GOOGLE_APPLICATION_CREDENTIALS=/path/to/sa-key.json\ngcloud services enable dataproc.googleapis.com --project my-project\n./toolbox","handlingStrategy":"validation","validationCode":"#!/usr/bin/env bash\n# Pre-flight GCP checks before starting the toolbox\nREGION=us-central1\n[ -n \"$GOOGLE_APPLICATION_CREDENTIALS\" ] || [ -f \"$HOME/.config/gcloud/application_default_credentials.json\" ] \\\n  || { echo \"No ADC credentials found\"; exit 1; }\nnc -zv \"$REGION-dataproc.googleapis.com\" 443 || { echo \"endpoint unreachable\"; exit 1; }\ngcloud services list --enabled --project my-project | grep -q dataproc.googleapis.com \\\n  || { echo \"Dataproc API not enabled\"; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Provision ADC (gcloud auth application-default login or a service account key) before launching.","Enable the Dataproc API in the target project.","Use a valid `location` region; the endpoint is derived as <location>-dataproc.googleapis.com.","Verify egress to googleapis.com:443 through firewalls/proxies."],"tags":["serverless-spark","dataproc","gcp","authentication","client"],"backgroundTag":"missing-gcp-credentials","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"}