googleapis/mcp-toolbox · error
failed to insert dry run job: %w
Error message
failed to insert dry run job: %w
What it means
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.
Source
Thrown at internal/tools/bigquery/bigquerycommon/util.go:82
JobReference: &bigqueryrestapi.JobReference{
ProjectId: projectID,
Location: location,
},
Configuration: &bigqueryrestapi.JobConfiguration{
DryRun: true,
Query: &bigqueryrestapi.JobConfigurationQuery{
Query: sql,
UseLegacySql: &useLegacySql,
ConnectionProperties: restConnProps,
QueryParameters: params,
MaximumBytesBilled: maximumBytesBilled,
},
},
}
insertResponse, err := restService.Jobs.Insert(projectID, jobToInsert).Context(ctx).Do()
if err != nil {
return nil, fmt.Errorf("failed to insert dry run job: %w", err)
}
return insertResponse, nil
}
// BQTypeStringFromToolType converts a tool parameter type string to a BigQuery standard SQL type string.
func BQTypeStringFromToolType(toolType string) (string, error) {
switch toolType {
case parameters.TypeString:
return "STRING", nil
case parameters.TypeInt:
return "INT64", nil
case parameters.TypeFloat:
return "FLOAT64", nil
case parameters.TypeBool:
return "BOOL", nil
case parameters.TypeMap:
return "STRUCT", nil
default:View on GitHub (pinned to 8cc6e09de2)
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
Example fix
// before resp, err := DryRunQuery(ctx, cfgWithoutCreds...) // after // ensure a token source is configured: client, _ := google.DefaultTokenSource(ctx, bigquery.CloudPlatformScope) resp, err := DryRunQuery(ctx, ..., client)
Defensive patterns
Strategy: try-catch
Validate before calling
// preflight: verify credentials and API access before dry runs
creds, err := google.FindDefaultCredentials(ctx, bigquery.CloudPlatformScope)
if err != nil {
return fmt.Errorf("no BigQuery credentials available: %w", err)
}
if projectID == "" {
return fmt.Errorf("project ID must be set before dry run")
} Try / catch
resp, err := DryRunQuery(ctx, ...)
if err != nil {
var retryable bool
if strings.Contains(err.Error(), "quota") || strings.Contains(err.Error(), "connection") || strings.Contains(err.Error(), "503") {
retryable = true // retry with exponential backoff
}
return fmt.Errorf("dry run failed (retryable=%v): %w", retryable, err)
} Prevention
- 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
When it happens
Trigger: Calling DryRunQuery when the underlying restService.Jobs.Insert(...).Do() request fails: invalid credentials/token, wrong projectID, BigQuery API disabled, network failure, or exceeded quota.
Common situations: 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.
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
- failed to verify allowedDataset '%s' in project '%s': %w
- unable to iterate through query results: %w
- failed to create BigQuery client for project %q: %w
- failed to create BigQuery v2 service: %w
- failed to send request: %w
AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05).
Data as JSON: /api/errors/15ae7058f77beedc.
Report an issue: GitHub.