{"record":{"id":"29a52b940160fe29","repo":"hasura/graphql-engine","slug":"bigquery-run-sql-api-request-failed-d","errorCode":null,"errorMessage":"bigquery_run_sql api request failed %d","messagePattern":"bigquery_run_sql api request failed (.+?)","errorType":"http","errorClass":"errors.Error","httpStatus":null,"severity":"error","filePath":"cli/internal/hasura/sourceops/bigquery/run_sql.go","lineNumber":37,"sourceCode":"\t\tType: \"bigquery_run_sql\",\n\t\tArgs: input,\n\t}\n\n\tb := new(bytes.Buffer)\n\n\tresp, err := d.send(body, b)\n\tif err != nil {\n\t\treturn nil, errors.E(op, err)\n\t}\n\n\tif resp.StatusCode != http.StatusOK {\n\t\tif b.Len() > 0 {\n\t\t\treturn nil, errors.E(op, errors.KindHasuraAPI, b.String())\n\t\t} else {\n\t\t\treturn nil, errors.E(\n\t\t\t\top,\n\t\t\t\terrors.KindHasuraAPI,\n\t\t\t\tfmt.Errorf(\"bigquery_run_sql api request failed %d\", resp.StatusCode),\n\t\t\t)\n\t\t}\n\t}\n\n\to := new(hasura.BigQueryRunSQLOutput)\n\tif err = json.NewDecoder(b).Decode(o); err != nil {\n\t\treturn nil, errors.E(op, err)\n\t}\n\n\treturn o, nil\n}\n","sourceCodeStart":19,"sourceCodeEnd":49,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/cli/internal/hasura/sourceops/bigquery/run_sql.go#L19-L49","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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","Verify the BigQuery source exists in metadata with kind 'bigquery' and correct connection string / credentials","Re-run with --debug on the CLI to capture the full HTTP exchange since the body is empty","If behind a proxy, bypass it or fix its error-page configuration so Hasura's error body reaches the CLI","Update CLI and server to matching versions that both support bigquery_run_sql"],"exampleFix":"// before\nout, err := c.BigQueryRunSQL(args)\nif err != nil {\n  return err\n}\n\n// after\nout, err := c.BigQueryRunSQL(args)\nif err != nil {\n  if strings.Contains(err.Error(), \"bigquery_run_sql api request failed\") {\n    // empty-body server rejection: surface status, check server logs\n    return fmt.Errorf(\"bigquery_run_sql rejected (see server logs): %w\", err)\n  }\n  return err\n}","handlingStrategy":"try-catch","validationCode":"// Confirm the bigquery source exists and is consistent before run_sql\n// POST /v1/metadata {\"type\":\"export_metadata\"} and verify a kind:\"bigquery\" source is present","typeGuard":"func isEmptyBodyAPIError(err error) bool {\n  return err != nil && strings.Contains(err.Error(), \"api request failed\")\n}","tryCatchPattern":"out, err := c.BigQueryRunSQL(args)\nif err != nil {\n  if isEmptyBodyAPIError(err) {\n    // no server message: branch on the embedded status, check server logs\n    return handleStatusOnly(err)\n  }\n  return err\n}","preventionTips":["Validate BigQuery credentials/source config in metadata before running migrations","Run with --debug when bodies are empty so the raw exchange is visible","Keep CLI and server versions aligned for source-kind support"],"tags":["hasura","bigquery","run-sql","http-status","api-error","go"],"backgroundTag":"hasura-metadata-api-error","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}