{"record":{"id":"2f5ffd73b07810be","repo":"hasura/graphql-engine","slug":"reading-metadata-failed-w","errorCode":null,"errorMessage":"reading metadata failed: %w","messagePattern":"reading metadata failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/commands/metadata_export.go","lineNumber":115,"sourceCode":"\t}\n\n\treturn nil\n}\n\nfunc getMetadataFromServerAndWriteToStdoutByFormat(\n\tec *cli.ExecutionContext,\n\tformat rawOutputFormat,\n) error {\n\tvar op errors.Op = \"commands.getMetadataFromServerAndWriteToStdoutByFormat\"\n\n\tmetadataReader, err := cli.GetCommonMetadataOps(ec).ExportMetadata()\n\tif err != nil {\n\t\treturn errors.E(op, fmt.Errorf(\"failed to export metadata: %w\", err))\n\t}\n\n\tjsonMetadata, err := io.ReadAll(metadataReader)\n\tif err != nil {\n\t\treturn errors.E(op, fmt.Errorf(\"reading metadata failed: %w\", err))\n\t}\n\n\tif err := writeByOutputFormat(ec.Stdout, jsonMetadata, format); err != nil {\n\t\treturn errors.E(op, err)\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":97,"sourceCodeEnd":124,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/cli/commands/metadata_export.go#L97-L124","documentation":"After a successful server export, the CLI reads the entire metadata response body with io.ReadAll; failure during that read (connection reset, stream closed prematurely, reader error) produces this error. The metadata was fetched but could not be fully transferred to memory.","triggerScenarios":"`hasura metadata export --output-format ...` where the HTTP response stream breaks mid-read: server closes connection early, network interruption between client and server, proxy timeouts on large metadata payloads.","commonSituations":"Large metadata payloads exceeding proxy/LB idle timeouts (504-style cuts), flaky connections to remote Hasura Cloud instances, or servers restarted mid-response.","solutions":["Retry the export — transient stream breaks often resolve themselves","If metadata is very large, increase proxy/load-balancer read timeouts between you and the server","Check server logs for OOM/crash during export; a large schema may need server resource bumps","Export from a network path closer to the server to rule out intermediary cuts"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"# Shell: size check via curl to anticipate large payloads\ncurl -s -o /dev/null -w '%{size_download}\\n' -H \"X-Hasura-Admin-Secret: $SECRET\" \\\n  \"$ENDPOINT/v1/metadata\" -d '{\"type\":\"export_metadata\"}'","typeGuard":null,"tryCatchPattern":"// Go: retry reads broken by transient network cuts\nvar b []byte\nvar err error\nfor i := 0; i < 3; i++ {\n  b, err = io.ReadAll(reader)\n  if err == nil { break }\n}","preventionTips":["Raise proxy/LB timeouts for large metadata","Stabilize network path to Hasura Cloud before exporting"],"tags":["io","metadata-export","network"],"backgroundTag":"connection-reset-midstream","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}