{"record":{"id":"03de8671de406eb7","repo":"hasura/graphql-engine","slug":"failed-parsing-json-w-response-from-api-s","errorCode":null,"errorMessage":"failed parsing json: %w; response from API: %s","messagePattern":"failed parsing json: %w; response from API: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/migrate/database/hasuradb/types.go","lineNumber":189,"sourceCode":"\t\treturn \"\"\n\t}\n\n\treturn strings.Join(errorStrings, \"\\r\\n\")\n}\n\n// NewHasuraError - returns error based on data and isCmd.\nfunc NewHasuraError(data []byte, isCmd bool) error {\n\tvar op errors.Op = \"hasuradb.NewHasuraError\"\n\n\tswitch isCmd {\n\tcase true:\n\t\tvar herror HasuraError\n\n\t\terr := json.Unmarshal(data, &herror)\n\t\tif err != nil {\n\t\t\treturn errors.E(\n\t\t\t\top,\n\t\t\t\tfmt.Errorf(\"failed parsing json: %w; response from API: %s\", err, string(data)),\n\t\t\t)\n\t\t}\n\n\t\treturn herror\n\tdefault:\n\t\treturn errors.E(op, fmt.Errorf(\"data error: %s\", string(data)))\n\t}\n}\n","sourceCodeStart":171,"sourceCodeEnd":198,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/cli/migrate/database/hasuradb/types.go#L171-L198","documentation":"NewHasuraError tries to unmarshal a non-2xx response body into HasuraError JSON; if the body is not valid JSON it wraps the parse failure plus the raw response text so nothing is hidden.","triggerScenarios":"Any hasuradb API call that returns an error response whose body is HTML (proxy error page, auth portal) or plain text instead of the expected Hasura error JSON.","commonSituations":"Hasura behind a reverse proxy returning 502/503 HTML pages, wrong endpoint pointing at a non-Hasura service, gateways requiring authentication, or a very old server without JSON error responses.","solutions":["Check the response snippet in the message to identify what actually answered (proxy? login page?)","Verify the HASURA_GRAPHQL_ENDPOINT URL points directly at the Hasura server","Fix proxy configuration or admin secret so real Hasura JSON errors are returned"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"resp, err := http.Get(endpoint + \"/healthz\")\nif err != nil || resp.StatusCode != 200 {\n    return fmt.Errorf(\"endpoint %s is not a healthy Hasura server\", endpoint)\n}","typeGuard":null,"tryCatchPattern":"// inspect message for raw body; if it contains '<html' the answer came from a proxy, not Hasura\nif err != nil && strings.Contains(err.Error(), \"<html\") {\n    // fix endpoint/proxy/admin secret instead of retrying\n}","preventionTips":["Point HASURA_GRAPHQL_ENDPOINT directly at the Hasura server","Configure admin secret so real JSON errors are returned"],"tags":["hasura","json","api","parsing"],"backgroundTag":"unexpected-api-response-format","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}