{"record":{"id":"15ae7058f77beedc","repo":"googleapis/mcp-toolbox","slug":"failed-to-insert-dry-run-job-w","errorCode":null,"errorMessage":"failed to insert dry run job: %w","messagePattern":"failed to insert dry run job: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/tools/bigquery/bigquerycommon/util.go","lineNumber":82,"sourceCode":"\t\tJobReference: &bigqueryrestapi.JobReference{\n\t\t\tProjectId: projectID,\n\t\t\tLocation:  location,\n\t\t},\n\t\tConfiguration: &bigqueryrestapi.JobConfiguration{\n\t\t\tDryRun: true,\n\t\t\tQuery: &bigqueryrestapi.JobConfigurationQuery{\n\t\t\t\tQuery:                sql,\n\t\t\t\tUseLegacySql:         &useLegacySql,\n\t\t\t\tConnectionProperties: restConnProps,\n\t\t\t\tQueryParameters:      params,\n\t\t\t\tMaximumBytesBilled:   maximumBytesBilled,\n\t\t\t},\n\t\t},\n\t}\n\n\tinsertResponse, err := restService.Jobs.Insert(projectID, jobToInsert).Context(ctx).Do()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to insert dry run job: %w\", err)\n\t}\n\treturn insertResponse, nil\n}\n\n// BQTypeStringFromToolType converts a tool parameter type string to a BigQuery standard SQL type string.\nfunc BQTypeStringFromToolType(toolType string) (string, error) {\n\tswitch toolType {\n\tcase parameters.TypeString:\n\t\treturn \"STRING\", nil\n\tcase parameters.TypeInt:\n\t\treturn \"INT64\", nil\n\tcase parameters.TypeFloat:\n\t\treturn \"FLOAT64\", nil\n\tcase parameters.TypeBool:\n\t\treturn \"BOOL\", nil\n\tcase parameters.TypeMap:\n\t\treturn \"STRUCT\", nil\n\tdefault:","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/bigquery/bigquerycommon/util.go#L64-L100","documentation":"DryRunQuery submits a query as a dry-run job to the BigQuery REST API (jobs.insert with configuration.dryRun=true). If the REST insert call returns an error (auth failure, invalid project, quota, malformed job), the error is wrapped with this message so callers can tell the dry-run submission itself failed as opposed to the query being invalid.","triggerScenarios":"Calling DryRunQuery when the underlying restService.Jobs.Insert(...).Do() request fails: invalid credentials/token, wrong projectID, BigQuery API disabled, network failure, or exceeded quota.","commonSituations":"Expired or missing service-account credentials; GOOGLE_APPLICATION_CREDENTIALS not set; BigQuery API not enabled on the project; transient network/DNS issues in CI; requesting dry runs at a rate above quota.","solutions":["Inspect the wrapped %w error for root cause; verify credentials (gcloud auth application-default login or service account key)","Confirm the project ID is correct and the BigQuery API is enabled","Retry with backoff if the error is transient (network/5xx/quota)","Check IAM permissions: the caller needs bigquery.jobs.create"],"exampleFix":"// before\nresp, err := DryRunQuery(ctx, cfgWithoutCreds...)\n// after\n// ensure a token source is configured:\nclient, _ := google.DefaultTokenSource(ctx, bigquery.CloudPlatformScope)\nresp, err := DryRunQuery(ctx, ..., client)","handlingStrategy":"try-catch","validationCode":"// preflight: verify credentials and API access before dry runs\ncreds, err := google.FindDefaultCredentials(ctx, bigquery.CloudPlatformScope)\nif err != nil {\n    return fmt.Errorf(\"no BigQuery credentials available: %w\", err)\n}\nif projectID == \"\" {\n    return fmt.Errorf(\"project ID must be set before dry run\")\n}","typeGuard":null,"tryCatchPattern":"resp, err := DryRunQuery(ctx, ...)\nif err != nil {\n    var retryable bool\n    if strings.Contains(err.Error(), \"quota\") || strings.Contains(err.Error(), \"connection\") || strings.Contains(err.Error(), \"503\") {\n        retryable = true // retry with exponential backoff\n    }\n    return fmt.Errorf(\"dry run failed (retryable=%v): %w\", retryable, err)\n}","preventionTips":["Verify service-account credentials and scopes before running dry runs","Enable the BigQuery API on the target project","Implement exponential backoff for transient API errors","Grant the caller bigquery.jobs.create IAM permission"],"tags":["bigquery","dry-run","network","google-api"],"backgroundTag":"api-request-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"}