{"record":{"id":"a0152a64b7b7a825","repo":"hasura/graphql-engine","slug":"reading-metadata-from-response-w","errorCode":null,"errorMessage":"reading metadata from response: %w","messagePattern":"reading metadata from response: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/commands/metadata_handlers.go","lineNumber":327,"sourceCode":"\t\treturn errors.E(op, err)\n\t}\n\n\treturn nil\n}\n\nfunc export(o *MetadataExportOptions, mode cli.MetadataMode) error {\n\tvar op errors.Op = \"commands.export\"\n\n\tmetadata, err := ec.APIClient.V1Metadata.ExportMetadata()\n\tif err != nil {\n\t\treturn errors.E(op, fmt.Errorf(\"exporting metadata from server: %w\", err))\n\t}\n\n\tvar metadataBytes []byte\n\n\tmetadataBytes, err = io.ReadAll(metadata)\n\tif err != nil {\n\t\treturn errors.E(op, fmt.Errorf(\"reading metadata from response: %w\", err))\n\t}\n\n\tif mode == cli.MetadataModeYAML {\n\t\tmetadataBytes, err = metadatautil.JSONToYAML(metadataBytes)\n\t\tif err != nil {\n\t\t\treturn errors.E(op, fmt.Errorf(\"parsing metadata to yaml: %w\", err))\n\t\t}\n\t}\n\n\terr = os.WriteFile(o.EC.MetadataFile, metadataBytes, os.ModePerm)\n\tif err != nil {\n\t\treturn errors.E(op, fmt.Errorf(\"writing metadata to file: %w\", err))\n\t}\n\n\treturn nil\n}\n\nfunc apply(o *MetadataApplyOptions, mode cli.MetadataMode) error {","sourceCodeStart":309,"sourceCodeEnd":345,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/cli/commands/metadata_handlers.go#L309-L345","documentation":"After `metadata export` successfully receives a streaming response from the server, the CLI reads the response body with io.ReadAll. This error indicates reading the response stream failed partway — the connection dropped, the response was truncated, or the stream was otherwise interrupted after the request was accepted.","triggerScenarios":"`metadata export` where ExportMetadata succeeds but io.ReadAll on the response body fails: connection reset mid-transfer, proxy timeouts on large metadata payloads, TLS renegotiation failures, or the server closing the stream early.","commonSituations":"Large metadata documents exceeding proxy/load-balancer timeouts; flaky networks or VPN drops mid-response; aggressive idle-timeout settings on ingress controllers; server crash while streaming the response.","solutions":["Retry the export — transient stream failures are the most common cause","Check for proxy/LB response timeouts and raise them if the metadata document is large","Inspect server logs to see if it terminated the response early (crash, OOM)","If reproducible, capture the response with curl to confirm whether truncation is network-side or server-side"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"err := export(opts, mode)\nfor attempt := 0; err != nil && attempt < 3; attempt++ {\n  if strings.Contains(err.Error(), \"reading metadata from response\") {\n    time.Sleep(time.Duration(attempt+1) * time.Second)\n    err = export(opts, mode)\n  }\n}","preventionTips":["Increase proxy/LB response timeouts for large metadata payloads","Retry exports on stream read failures — usually transient","Avoid networks known to drop long-lived connections, or export from closer to the server"],"tags":["metadata","export","network","response-stream","cli","go"],"backgroundTag":"response-read-failed","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}