{"record":{"id":"6767774fdda27280","repo":"hashicorp/nomad","slug":"failed-to-read-stream-v","errorCode":null,"errorMessage":"failed to read stream: %v","messagePattern":"failed to read stream: (.+?)","errorType":"http","errorClass":null,"httpStatus":400,"severity":"error","filePath":"nomad/operator_endpoint.go","lineNumber":704,"sourceCode":"\t\treturn\n\t} else if !aclObj.IsManagement() {\n\t\thandleFailure(403, structs.ErrPermissionDenied)\n\t\treturn\n\t}\n\n\top.srv.setQueryMeta(&reply.QueryMeta)\n\n\treader, errCh := decodeStreamOutput(decoder)\n\n\terr = snapshot.Restore(op.logger.Named(\"snapshot\"), reader, op.srv.raft)\n\tif err != nil {\n\t\thandleFailure(500, fmt.Errorf(\"failed to restore from snapshot: %v\", err))\n\t\treturn\n\t}\n\n\terr = <-errCh\n\tif err != nil {\n\t\thandleFailure(400, fmt.Errorf(\"failed to read stream: %v\", err))\n\t\treturn\n\t}\n\n\t// This'll be used for feedback from the leader loop.\n\ttimeoutCh := time.After(time.Minute)\n\n\tlerrCh := make(chan error, 1)\n\n\tselect {\n\t// Reassert leader actions and update all leader related state\n\t// with new state store content.\n\tcase op.srv.reassertLeaderCh <- lerrCh:\n\n\t// We might have lost leadership while waiting to kick the loop.\n\tcase <-timeoutCh:\n\t\thandleFailure(500, fmt.Errorf(\"timed out waiting to re-run leader actions\"))\n\n\t// Make sure we don't get stuck during shutdown","sourceCodeStart":686,"sourceCodeEnd":722,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/operator_endpoint.go#L686-L722","documentation":"Indicates the error channel from decodeStreamOutput yielded an error after snapshot.Restore was initiated — i.e. reading the client's streamed snapshot input failed partway through (decode or read error on the pipe). Returns 400 to the client.","triggerScenarios":"The client-side stream (from 'nomad operator snapshot restore' or decodeStreamOutput's decoder goroutine) hits a decode error, EOF mid-stream, or connection drop; the goroutine forwards it via errCh.","commonSituations":"Network drop between client and leader during restore; the pushed file was truncated or is not a valid Nomad snapshot archive.","solutions":["Verify the snapshot file is complete and valid (nomad operator snapshot inspect)","Re-run the restore over a reliable connection","Check client logs for the streaming/upload error to find the root cause","Confirm no proxy is buffering or truncating large request bodies"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"err := client.Operator().SnapshotRestore(r, nil, nil)\nif err != nil && strings.Contains(err.Error(), \"failed to read stream\") {\n    // input stream was cut: re-open reader and retry\n}","preventionTips":["Use stable, low-latency paths for snapshot push","Avoid proxies that truncate long request bodies","Validate snapshot file completeness before pushing"],"tags":["streaming","rpc","snapshot","decode"],"backgroundTag":"stream-read-failed","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}