{"record":{"id":"919054e88280cbb5","repo":"hashicorp/nomad","slug":"failed-to-decode-input-v","errorCode":null,"errorMessage":"failed to decode input: %v","messagePattern":"failed to decode input: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/operator_endpoint.go","lineNumber":840,"sourceCode":"\treply.QueryMeta.Index, _ = op.srv.State().LatestIndex()\n\top.srv.setQueryMeta(&reply.QueryMeta)\n\n\treturn nil\n}\n\nfunc decodeStreamOutput(decoder *codec.Decoder) (io.Reader, <-chan error) {\n\tpr, pw := io.Pipe()\n\terrCh := make(chan error, 1)\n\n\tgo func() {\n\t\tdefer close(errCh)\n\n\t\tfor {\n\t\t\tvar wrapper cstructs.StreamErrWrapper\n\n\t\t\terr := decoder.Decode(&wrapper)\n\t\t\tif err != nil {\n\t\t\t\tpw.CloseWithError(fmt.Errorf(\"failed to decode input: %v\", err))\n\t\t\t\terrCh <- err\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tif len(wrapper.Payload) != 0 {\n\t\t\t\t_, err = pw.Write(wrapper.Payload)\n\t\t\t\tif err != nil {\n\t\t\t\t\tpw.CloseWithError(err)\n\t\t\t\t\terrCh <- err\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif errW := wrapper.Error; errW != nil {\n\t\t\t\tif errW.Message == io.EOF.Error() {\n\t\t\t\t\tpw.CloseWithError(io.EOF)\n\t\t\t\t} else {\n\t\t\t\t\tpw.CloseWithError(errors.New(errW.Message))","sourceCodeStart":822,"sourceCodeEnd":858,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/operator_endpoint.go#L822-L858","documentation":"Inside decodeStreamOutput's goroutine, when decoder.Decode(&wrapper) fails while reading a streamed snapshot from the RPC connection, the pipe writer is closed with this error and the error is forwarded on errCh. It surfaces as a 400 in snapshotRestore's 'failed to read stream' path.","triggerScenarios":"The msgpack decoder hits EOF (connection closed early), malformed bytes, or a wrapped StreamErrWrapper carrying a server-side error payload.","commonSituations":"Client upload interrupted mid-restore; the pushed snapshot bytes are not valid msgpack stream framing; network proxy truncating the request body.","solutions":["Verify the snapshot file integrity before pushing (checksum / nomad operator snapshot inspect)","Re-run the restore over a stable connection","Check for proxies that cut long uploads; increase request-body timeouts","Look at errCh logs to distinguish EOF (connection drop) vs decode (corrupt data) errors"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"fi, err := os.Stat(snapPath)\nif err != nil || fi.Size() == 0 { return errors.New(\"snapshot file missing or empty\") }\nsum, _ := snapChecksum(snapPath)\nif sum != expectedSum { return errors.New(\"snapshot checksum mismatch\") }","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"failed to read stream\") {\n    // decode/read of pushed stream failed: revalidate file and retry\n}","preventionTips":["Checksum snapshot files before pushing","Test snapshot validity with 'nomad operator snapshot inspect'","Keep the connection alive for the full upload duration"],"tags":["decode","streaming","msgpack","rpc"],"backgroundTag":"stream-decode-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"}