{"record":{"id":"b8927119f316768d","repo":"hasura/graphql-engine","slug":"api-request-to-v-failed-code-v","errorCode":null,"errorMessage":"API request to %v failed, code: %v","messagePattern":"API request to (.+?) failed, code: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/internal/hasura/v1version/version.go","lineNumber":43,"sourceCode":"\nfunc (c *Client) GetVersion() (*hasura.V1VersionResponse, error) {\n\tvar op errors.Op = \"v1version.Client.GetVersion\"\n\n\tb := new(bytes.Buffer)\n\n\tresp, err := c.send(nil, 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(\"API request to %v failed, code: %v\", c.path, resp.StatusCode),\n\t\t\t)\n\t\t}\n\t}\n\n\to := new(hasura.V1VersionResponse)\n\tif err := json.NewDecoder(b).Decode(o); err != nil {\n\t\treturn nil, errors.E(op, fmt.Errorf(\"decoding API response failed for: %v\", c.path))\n\t}\n\n\treturn o, nil\n}\n\nfunc (c *Client) send(body any, responseBodyWriter io.Writer) (*httpc.Response, error) {\n\tvar op errors.Op = \"v1version.Client.send\"\n\n\treq, err := c.NewRequest(http.MethodGet, c.path, body)\n\tif err != nil {\n\t\treturn nil, errors.E(op, err)","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/cli/internal/hasura/v1version/version.go#L25-L61","documentation":"Returned by the v1version client's GetVersion when the request to the /v1/version endpoint succeeds at the transport level but returns a non-OK HTTP status and the response body is empty (when the body is non-empty, the body itself is used as the error instead). It is tagged KindHasuraAPI, indicating the Hasura server rejected or failed the request.","triggerScenarios":"Calling GetVersion (e.g. `hasura version` or CLI commands that probe server version) against a URL that returns an empty-body error: 404 from a wrong path or reverse-proxy route, 401/403 from a missing admin secret, 502/503 from a gateway in front of Hasura.","commonSituations":"Typo in --endpoint, pointing at a GraphQL route instead of the server root, load balancers returning empty 502 responses, or hitting an endpoint that requires auth without supplying the admin secret.","solutions":["Confirm the endpoint URL points at the Hasura server root (e.g. http://localhost:8080), not /v1/graphql","Check that any required admin secret/TLS config is passed to the client","Curl the endpoint manually: curl -i <endpoint>/v1/version to see the raw status","If behind a proxy, inspect proxy logs for why the response is empty"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"resp, err := http.Head(endpoint + \"/v1/version\")\nif err != nil || resp.StatusCode != http.StatusOK {\n\t// fix endpoint/auth before calling GetVersion\n}","typeGuard":"func isHasuraAPIError(err error) bool {\n\tvar e *errors.Error\n\treturn errors.As(err, &e) && e.Kind == errors.KindHasuraAPI\n}","tryCatchPattern":"v, err := client.GetVersion()\nif err != nil {\n\tif isHasuraAPIError(err) { /* endpoint/auth problem: check URL and admin secret */ }\n\treturn err\n}","preventionTips":["Use the server root URL, not the /v1/graphql path","Probe /v1/version with curl when config changes","Supply admin secret when the endpoint requires it"],"tags":["hasura","version-check","http-status","endpoint-config"],"backgroundTag":"http-request-failed-non-200","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}