hasura/graphql-engine · error · errors.Error

bigquery_run_sql api request failed %d

Error message

bigquery_run_sql api request failed %d

What it means

BigQueryRunSQL returns this error when the Hasura server answers the bigquery_run_sql metadata API call with a non-200 status AND an empty response body. Because the body is empty, the CLI cannot surface a server-provided message and falls back to printing only the HTTP status code. It is tagged errors.KindHasuraAPI, meaning the request reached the server but was rejected before producing a GraphQL/metadata result.

Source

Thrown at cli/internal/hasura/sourceops/bigquery/run_sql.go:37

		Type: "bigquery_run_sql",
		Args: input,
	}

	b := new(bytes.Buffer)

	resp, err := d.send(body, b)
	if err != nil {
		return nil, errors.E(op, err)
	}

	if resp.StatusCode != http.StatusOK {
		if b.Len() > 0 {
			return nil, errors.E(op, errors.KindHasuraAPI, b.String())
		} else {
			return nil, errors.E(
				op,
				errors.KindHasuraAPI,
				fmt.Errorf("bigquery_run_sql api request failed %d", resp.StatusCode),
			)
		}
	}

	o := new(hasura.BigQueryRunSQLOutput)
	if err = json.NewDecoder(b).Decode(o); err != nil {
		return nil, errors.E(op, err)
	}

	return o, nil
}

View on GitHub (pinned to 724551b9ae)

Solutions

  1. Check the HTTP status embedded in the message: 401/403 → fix admin secret; 404 → source kind or endpoint not supported; 5xx → inspect Hasura server logs for the real cause
  2. Verify the BigQuery source exists in metadata with kind 'bigquery' and correct connection string / credentials
  3. Re-run with --debug on the CLI to capture the full HTTP exchange since the body is empty
  4. If behind a proxy, bypass it or fix its error-page configuration so Hasura's error body reaches the CLI
  5. Update CLI and server to matching versions that both support bigquery_run_sql

Example fix

// before
out, err := c.BigQueryRunSQL(args)
if err != nil {
  return err
}

// after
out, err := c.BigQueryRunSQL(args)
if err != nil {
  if strings.Contains(err.Error(), "bigquery_run_sql api request failed") {
    // empty-body server rejection: surface status, check server logs
    return fmt.Errorf("bigquery_run_sql rejected (see server logs): %w", err)
  }
  return err
}
Defensive patterns

Strategy: try-catch

Validate before calling

// Confirm the bigquery source exists and is consistent before run_sql
// POST /v1/metadata {"type":"export_metadata"} and verify a kind:"bigquery" source is present

Type guard

func isEmptyBodyAPIError(err error) bool {
  return err != nil && strings.Contains(err.Error(), "api request failed")
}

Try / catch

out, err := c.BigQueryRunSQL(args)
if err != nil {
  if isEmptyBodyAPIError(err) {
    // no server message: branch on the embedded status, check server logs
    return handleStatusOnly(err)
  }
  return err
}

Prevention

When it happens

Trigger: Invoking bigquery_run_sql (e.g. during 'hasura migrate apply' against a BigQuery source) where the server returns 401/403 (bad admin secret), 404 (source kind not registered or wrong API path), 500 with an empty body (BigQuery project/credentials misconfigured on the server), or when a proxy/gateway in front of Hasura strips the error body.

Common situations: Wrong or expired GCP service account credentials configured for the BigQuery source, mismatched admin secret, pointing the CLI at a server built without the bigquery backend plugin, or a reverse proxy (nginx, load balancer) that rewrites 5xx responses without a body.

Related errors


AI-assisted analysis of hasura/graphql-engine@724551b9ae (2026-08-28). Data as JSON: /api/errors/29a52b940160fe29. Report an issue: GitHub.