{"record":{"id":"f38fadca13233342","repo":"googleapis/mcp-toolbox","slug":"failed-to-create-bigquery-v2-service-w","errorCode":null,"errorMessage":"failed to create BigQuery v2 service: %w","messagePattern":"failed to create BigQuery v2 service: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/bigquery/bigquery.go","lineNumber":825,"sourceCode":"\n\tif endpoint != \"\" {\n\t\topts = append(opts, option.WithEndpoint(endpoint))\n\t}\n\tif quotaProject != \"\" {\n\t\topts = append(opts, option.WithQuotaProject(quotaProject))\n\t}\n\n\t// Initialize the high-level BigQuery client\n\tclient, err := bigqueryapi.NewClient(ctx, project, opts...)\n\tif err != nil {\n\t\treturn nil, nil, nil, fmt.Errorf(\"failed to create BigQuery client for project %q: %w\", project, err)\n\t}\n\tclient.Location = location\n\n\t// Initialize the low-level BigQuery REST service using the same credentials\n\trestService, err := bigqueryrestapi.NewService(ctx, opts...)\n\tif err != nil {\n\t\treturn nil, nil, nil, fmt.Errorf(\"failed to create BigQuery v2 service: %w\", err)\n\t}\n\n\treturn client, restService, tokenSource, nil\n}\n\n// initBigQueryConnectionWithOAuthToken initialize a BigQuery client with an\n// OAuth access token.\nfunc initBigQueryConnectionWithOAuthToken(\n\tctx context.Context,\n\ttracer trace.Tracer,\n\tproject string,\n\tlocation string,\n\tquotaProject string,\n\tname string,\n\tuserAgent string,\n\ttokenString string,\n\twantRestService bool,\n\tendpoint string,","sourceCodeStart":807,"sourceCodeEnd":843,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/bigquery/bigquery.go#L807-L843","documentation":"This error is thrown when the low-level BigQuery REST service (google.golang.org/api/bigquery/v2) fails to initialize via bigqueryrestapi.NewService using the same client options as the high-level client. The toolbox builds both a high-level bigquery.Client and a raw REST service; failure here means the REST layer could not be created even though the high-level client succeeded. Wrapped causes are usually option validation or transport setup failures.","triggerScenarios":"bigqueryrestapi.NewService(ctx, opts...) returns an error while constructing the REST client from the same opts (user agent, token source/credentials, quota project) — e.g. invalid option combination, failure resolving the API endpoint, or transport/credentials setup errors inside the google-api-go-client.","commonSituations":"Custom base URL / endpoint misconfiguration; proxy or firewall interfering with API endpoint resolution; incompatible or conflicting option.WithTokenSource plus option.WithCredentials values; intermittent transport errors during service construction.","solutions":["Inspect the wrapped error with errors.As/Unwrap to identify the exact cause.","Verify any custom endpoint/base-URL option is a valid BigQuery v2 API URL.","Ensure only one credential mechanism (token source or credentials) is applied consistently.","Check network/proxy access to bigquery.googleapis.com and retry if transient."],"exampleFix":"// before\nopts := []option.ClientOption{\n  option.WithUserAgent(userAgent),\n  option.WithTokenSource(ts),\n  option.WithCredentials(cred), // conflicting credential options\n}\n// after\nopts := []option.ClientOption{\n  option.WithUserAgent(userAgent),\n  option.WithTokenSource(ts), // single credential mechanism\n}","handlingStrategy":"try-catch","validationCode":"// Validate connectivity to the BigQuery v2 endpoint first\nresp, err := http.Get(\"https://bigquery.googleapis.com/\")\nif err != nil {\n  return fmt.Errorf(\"BigQuery API endpoint unreachable: %w\", err)\n}\nresp.Body.Close()","typeGuard":null,"tryCatchPattern":"// Go\nclient, rest, ts, err := initBigQueryConnection(ctx, cfg)\nif err != nil && strings.Contains(err.Error(), \"failed to create BigQuery v2 service\") {\n  // transient? retry once with backoff before failing startup\n  time.Sleep(2 * time.Second)\n  client, rest, ts, err = initBigQueryConnection(ctx, cfg)\n  if err != nil {\n    log.Fatalf(\"BigQuery v2 REST service init failed: %v — check endpoint/proxy and credential options\", err)\n  }\n}","preventionTips":["Avoid mixing option.WithTokenSource and option.WithCredentials in the same options slice.","Check network/proxy access to bigquery.googleapis.com.","If using a custom endpoint, verify it is a valid BigQuery v2 API URL.","Retry service construction once on transient transport errors."],"tags":["bigquery","rest-client","client-initialization","network"],"backgroundTag":"api-service-initialization-failed","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"}