{"record":{"id":"bc9940806dce42ca","repo":"hasura/graphql-engine","slug":"s-d-s","errorCode":null,"errorMessage":" %s: %d \n%s","messagePattern":" %s: %d \n%s","errorType":"http","errorClass":"errors.Error","httpStatus":null,"severity":"error","filePath":"cli/internal/hasura/v1graphql/v1graphql.go","lineNumber":45,"sourceCode":"\tvar op errors.Op = \"v1graphql.Client.GetIntrospectionSchema\"\n\n\topName := \"getIntrospectionSchema \"\n\tquery := map[string]string{\n\t\t\"query\": \"\\n    query IntrospectionQuery {\\n      __schema {\\n        queryType { name }\\n        mutationType { name }\\n        subscriptionType { name }\\n        types {\\n          ...FullType\\n        }\\n        directives {\\n          name\\n          description\\n          locations\\n          args {\\n            ...InputValue\\n          }\\n        }\\n      }\\n    }\\n\\n    fragment FullType on __Type {\\n      kind\\n      name\\n      description\\n      fields(includeDeprecated: true) {\\n        name\\n        description\\n        args {\\n          ...InputValue\\n        }\\n        type {\\n          ...TypeRef\\n        }\\n        isDeprecated\\n        deprecationReason\\n      }\\n      inputFields {\\n        ...InputValue\\n      }\\n      interfaces {\\n        ...TypeRef\\n      }\\n      enumValues(includeDeprecated: true) {\\n        name\\n        description\\n        isDeprecated\\n        deprecationReason\\n      }\\n      possibleTypes {\\n        ...TypeRef\\n      }\\n    }\\n\\n    fragment InputValue on __InputValue {\\n      name\\n      description\\n      type { ...TypeRef }\\n      defaultValue\\n    }\\n\\n    fragment TypeRef on __Type {\\n      kind\\n      name\\n      ofType {\\n        kind\\n        name\\n        ofType {\\n          kind\\n          name\\n          ofType {\\n            kind\\n            name\\n            ofType {\\n              kind\\n              name\\n              ofType {\\n                kind\\n                name\\n                ofType {\\n                  kind\\n                  name\\n                  ofType {\\n                    kind\\n                    name\\n                  }\\n                }\\n              }\\n            }\\n          }\\n        }\\n      }\\n    }\\n  \",\n\t}\n\tresponseBody := new(bytes.Buffer)\n\n\tvar respBody struct {\n\t\tData   *json.RawMessage `json:\"data\"`\n\t\tErrors *json.RawMessage `json:\"errors\"`\n\t}\n\n\tresponse, err := c.send(query, responseBody)\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(\" %s: %d \\n%s\", opName, response.StatusCode, responseBody.String()),\n\t\t)\n\t}\n\n\tif err != nil {\n\t\treturn nil, errors.E(op, err)\n\t}\n\n\terr = json.NewDecoder(responseBody).Decode(&respBody)\n\tif err != nil {\n\t\treturn nil, errors.E(op, err)\n\t}\n\n\tif respBody.Errors != nil {\n\t\tvar b []byte\n\n\t\terr := respBody.Errors.UnmarshalJSON(b)\n\t\tif err != nil {\n\t\t\treturn nil, errors.E(","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/cli/internal/hasura/v1graphql/v1graphql.go#L27-L63","documentation":"GetIntrospectionSchema returns this error when the HTTP response to a GraphQL introspection query sent to the server's v1/graphql endpoint has a status code other than 200. The message embeds the operation name, status code, and the raw body (which may hold a proxy error page or Hasura error JSON). It is classified errors.KindHasuraAPI — the server or an intermediary rejected the request outright.","triggerScenarios":"Calling GetIntrospectionSchema (used by metadata export/inconsistency flows) when the endpoint URL is wrong (404), the admin secret is missing/wrong (401/403), introspection is disabled via HASURA_GRAPHQL_ENABLE_INTROSPECTION=false, or a gateway in front of Hasura returns 502/503 while the server restarts.","commonSituations":"CLI configured with an endpoint that includes or omits /v1/graphql incorrectly, expired or mistyped admin secret, introspection disabled on locked-down production instances, or transient 5xx during server deploys.","solutions":["Confirm the configured endpoint is the server base URL and the client appends /v1/graphql correctly; fix the URL if a 404","Supply the correct admin secret (env var or config) for 401/403 responses","Re-enable introspection (HASURA_GRAPHQL_ENABLE_INTROSPECTION=true) or export metadata from a server where it is allowed","Retry on transient 5xx after confirming server health via /healthz","Inspect the embedded response body — proxy HTML error pages reveal infrastructure causes"],"exampleFix":"// before\nschema, err := c.GetIntrospectionSchema()\nif err != nil { return err }\n\n// after\nschema, err := c.GetIntrospectionSchema()\nif err != nil {\n  if strings.Contains(err.Error(), \"introspection\") && err != nil {\n    return fmt.Errorf(\"introspection query rejected; check endpoint, admin secret, introspection flag: %w\", err)\n  }\n  return err\n}","handlingStrategy":"try-catch","validationCode":"// Pre-flight the graphql endpoint\nreq, _ := http.NewRequest(http.MethodPost, endpoint+\"/v1/graphql\", strings.NewReader(`{\"query\":\"{ __typename }\"}`))\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(\"graphql endpoint not ready: status %d, err %v\", resp.StatusCode, err)\n}","typeGuard":"func isIntrospectionHTTPError(err error) bool {\n  return err != nil && strings.Contains(err.Error(), \": 40\") || strings.Contains(err.Error(), \": 50\")\n}","tryCatchPattern":"schema, err := c.GetIntrospectionSchema()\nif err != nil {\n  if isHasuraAPIError(err) {\n    // parse embedded 'opName: status\\nbody' and branch on 404/401/403/5xx\n    return diagnoseHTTP(err)\n  }\n  return err\n}","preventionTips":["Store the base endpoint in config; let the client append /v1/graphql","Ensure introspection is enabled on target servers","Add retry with backoff for transient 502/503 during deploys"],"tags":["hasura","graphql","introspection","http-status","api-error","go"],"backgroundTag":"graphql-introspection-failed","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}