{"record":{"id":"47867e3e45679191","repo":"hasura/graphql-engine","slug":"pg-dump-request-d-s","errorCode":null,"errorMessage":"pg_dump request: %d \n%s","messagePattern":"pg_dump request: (.+?) \n(.+?)","errorType":"http","errorClass":"errors.Error","httpStatus":null,"severity":"error","filePath":"cli/internal/hasura/pgdump/pgdump.go","lineNumber":55,"sourceCode":"\n\treturn resp, nil\n}\n\nfunc (c *Client) Send(request hasura.PGDumpRequest) (io.Reader, error) {\n\tvar op errors.Op = \"pgdump.Client.Send\"\n\n\tresponseBody := new(bytes.Buffer)\n\n\tresponse, err := c.send(request, responseBody)\n\tif err != nil {\n\t\treturn nil, errors.E(op, err)\n\t}\n\n\tif response.StatusCode != http.StatusOK {\n\t\treturn nil, errors.E(\n\t\t\top,\n\t\t\terrors.KindHasuraAPI,\n\t\t\tfmt.Errorf(\"pg_dump request: %d \\n%s\", response.StatusCode, responseBody.String()),\n\t\t)\n\t}\n\n\treturn responseBody, nil\n}\n","sourceCodeStart":37,"sourceCodeEnd":61,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/cli/internal/hasura/pgdump/pgdump.go#L37-L61","documentation":"This error is returned by the pg_dump client's Send function in the Hasura CLI when the Hasura server responds to the /v1alpha1/pg_dump request with any HTTP status other than 200. It is wrapped with errors.KindHasuraAPI, so it represents a server-side rejection of the pg_dump API call rather than a transport failure. The message includes the HTTP status code and the raw response body, which usually contains the server's JSON error explaining the refusal (e.g. metadata inconsistent, permission denied, or unsupported operation).","triggerScenarios":"Calling pg_dump.Send (used by 'hasura3 migrate apply / export' flows) against a Hasura instance that answers non-200: e.g. 401/403 when the admin secret is wrong or missing, 404 on server versions without the pg_dump API, 500 when the source database is unreachable or metadata is inconsistent, or 400 when the selected source/database options are invalid.","commonSituations":"Running CLI commands against a Hasura Cloud vs OSS server of a different version, an incorrect HASURA_GRAPHQL_ADMIN_SECRET in the environment or config, a disconnected or misconfigured database source in metadata, or an inconsistent metadata state on the server after failed migrations.","solutions":["Read the response body embedded in the message — it contains the server's actual error (path, permission, or metadata problem) and dictates the fix","Verify HASURA_GRAPHQL_ADMIN_SECRET / --admin-secret matches the target server","Confirm the Hasura server version supports pg_dump (v2 DDN / v1alpha1 pg_dump endpoint) by hitting the /v1/version endpoint","Fix the server state: reconnect the source database and resolve metadata inconsistencies via the /v1/metadata endpoint before retrying","Retry with a fresh CLI version matching your server generation if the endpoint returns 404"],"exampleFix":"// before\nbody, err := client.Send(req)\nif err != nil {\n  log.Fatalf(\"pg_dump failed: %v\", err) // opaque\n}\n\n// after\nbody, err := client.Send(req)\nif err != nil {\n  var e hasura.ErrHasuraAPI\n  if errors.As(err, &e) {\n    log.Fatalf(\"pg_dump failed (HTTP %d): %s\", e.StatusCode, e.Body)\n  }\n  log.Fatalf(\"pg_dump failed: %v\", err)\n}","handlingStrategy":"try-catch","validationCode":"// Verify server reachability and admin secret before pg_dump\nreq, _ := http.NewRequest(http.MethodGet, endpoint+\"/v1/version\", nil)\nreq.Header.Set(\"X-Hasura-Admin-Secret\", adminSecret)\nresp, err := http.DefaultClient.Do(req)\nif err != nil || resp.StatusCode != http.StatusOK {\n  return fmt.Errorf(\"server not ready for pg_dump: %v / status %d\", err, resp.StatusCode)\n}","typeGuard":"func isHasuraAPIError(err error) bool {\n  var e *errors.Error\n  return errors.As(err, &e) && e.Kind() == errors.KindHasuraAPI\n}","tryCatchPattern":"body, err := client.Send(req)\nif err != nil {\n  if isHasuraAPIError(err) {\n    // status + body are embedded in err.Error(); parse and branch on 401/404/5xx\n    log.Printf(\"pg_dump rejected by server: %v\", err)\n    return diagnose(err)\n  }\n  return err // transport failure\n}","preventionTips":["Always set the admin secret via env var or config instead of retyping it","Check /v1/version matches a pg_dump-capable server before running export commands","Resolve metadata inconsistencies before running pg_dump-dependent flows"],"tags":["hasura","pg-dump","http-status","api-error","go"],"backgroundTag":"hasura-api-error","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}