{"record":{"id":"cd05eca3aa303720","repo":"hasura/graphql-engine","slug":"bulk-request-failed-v-v","errorCode":null,"errorMessage":"bulk request failed: %v %v","messagePattern":"bulk request failed: (.+?) (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/internal/hasura/v1query/v1_query.go","lineNumber":77,"sourceCode":"\t\tType: \"bulk\",\n\t\tArgs: args,\n\t}\n\n\treq, err := c.NewRequest(http.MethodPost, c.path, body)\n\tif err != nil {\n\t\treturn nil, errors.E(op, err)\n\t}\n\n\tresponseBody := new(bytes.Buffer)\n\n\tresp, err := c.LockAndDo(context.Background(), req, responseBody)\n\tif err != nil {\n\t\treturn nil, errors.E(op, err)\n\t} else if resp.StatusCode != http.StatusOK {\n\t\treturn nil, errors.E(\n\t\t\top,\n\t\t\terrors.KindHasuraAPI,\n\t\t\tfmt.Errorf(\"bulk request failed: %v %v\", resp.StatusCode, responseBody.String()),\n\t\t)\n\t}\n\n\treturn responseBody, nil\n}\n","sourceCodeStart":59,"sourceCodeEnd":83,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/cli/internal/hasura/v1query/v1_query.go#L59-L83","documentation":"Thrown by the Hasura CLI's v1query Bulk client when a bulk API request to the Hasura server completes but the HTTP response status is not 200. The error message embeds the status code and the raw response body, so the server-side rejection reason (often a GraphQL/metadata error payload) is visible in the message itself. It is wrapped with errors.KindHasuraAPI to mark it as a server API failure rather than a transport failure.","triggerScenarios":"Calling Bulk(...) with a list of v1 queries (e.g. metadata reload/export/apply batches) against a Hasura instance that returns a non-200 status: 400 for malformed query bodies, 401/404 when the endpoint path or admin secret is wrong, 500 when the server fails to process one of the bulked queries.","commonSituations":"Wrong or missing X-Hasura-Admin-Secret header (401), pointing the CLI at a Hasura Cloud endpoint vs. CE with mismatched API paths, sending a metadata object the server version doesn't support, or a server-side crash mid-batch during `hasura metadata apply`.","solutions":["Read the response body embedded in the message — it usually contains the exact Hasura error (e.g. 'x-hasura-admin-secret missing' or a metadata validation error)","Verify the endpoint and admin secret configuration used to construct the v1query client","Reproduce with a single query instead of a bulk to isolate which item in the batch fails","Check Hasura server logs if the body is unhelpful or the status is 5xx"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-check server reachability and auth before issuing the bulk call\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 { /* fix endpoint/secret first */ }","typeGuard":"func isHasuraAPIError(err error) bool {\n\tvar e *errors.Error\n\treturn errors.As(err, &e) && e.Kind == errors.KindHasuraAPI\n}","tryCatchPattern":"body, err := client.Bulk(queries)\nif err != nil {\n\tif isHasuraAPIError(err) {\n\t\t// message contains status + server body; surface it, do not retry blindly\n\t\treturn fmt.Errorf(\"hasura rejected bulk request: %w\", err)\n\t}\n\treturn err // transport error: retryable\n}","preventionTips":["Validate endpoint and admin secret with a cheap /v1/version call before bulk operations","Keep metadata queries within the schema supported by the target server version","Log the full error message — the embedded response body pinpoints the failing query"],"tags":["hasura","http-status","bulk-api","metadata"],"backgroundTag":"http-request-failed-non-200","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}