{"record":{"id":"437e7b0678f34b94","repo":"hyperledger/fabric","slug":"cannot-read-file-part-s-from-request-body","errorCode":null,"errorMessage":"cannot read file part %s from request body","messagePattern":"cannot read file part (.+?) from request body","errorType":"http","errorClass":null,"httpStatus":400,"severity":"error","filePath":"orderer/common/channelparticipation/restapi.go","lineNumber":455,"sourceCode":"\t\th.sendResponseJsonError(resp, http.StatusBadRequest, errors.Errorf(\"form does not contains part key: %s\", FormDataConfigBlockKey))\n\t\treturn nil\n\t}\n\n\tif len(form.File) != 1 || len(form.Value) != 0 {\n\t\th.sendResponseJsonError(resp, http.StatusBadRequest, errors.New(\"form contains too many parts\"))\n\t\treturn nil\n\t}\n\n\tfileHeader := form.File[FormDataConfigBlockKey][0]\n\tfile, err := fileHeader.Open()\n\tif err != nil {\n\t\th.sendResponseJsonError(resp, http.StatusBadRequest, errors.Wrapf(err, \"cannot open file part %s from request body\", FormDataConfigBlockKey))\n\t\treturn nil\n\t}\n\n\tblockBytes, err := io.ReadAll(file)\n\tif err != nil {\n\t\th.sendResponseJsonError(resp, http.StatusBadRequest, errors.Wrapf(err, \"cannot read file part %s from request body\", FormDataConfigBlockKey))\n\t\treturn nil\n\t}\n\n\tblock := &cb.Block{}\n\terr = proto.Unmarshal(blockBytes, block)\n\tif err != nil {\n\t\th.logger.Debugf(\"Failed to unmarshal blockBytes: %s\", err)\n\t\th.sendResponseJsonError(resp, http.StatusBadRequest, errors.Wrapf(err, \"cannot unmarshal file part %s into a block\", FormDataConfigBlockKey))\n\t\treturn nil\n\t}\n\n\treturn block\n}\n\n// Expect a multipart/form-data with a single part, of type file, with key FormDataConfigUpdateEnvelopeKey.\nfunc (h *HTTPHandler) multipartFormDataBodyToEnvelope(params map[string]string, req *http.Request, resp http.ResponseWriter) *cb.Envelope {\n\tboundary := params[\"boundary\"]\n\treader := multipart.NewReader(","sourceCodeStart":437,"sourceCodeEnd":473,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/orderer/common/channelparticipation/restapi.go#L437-L473","documentation":"This error wraps the error from io.ReadAll when the server could read the file header but failed reading the full contents of the 'config-block' file part from the request body. It is returned as HTTP 400 and indicates the byte stream for the uploaded block was interrupted or unreadable, so the genesis/config block bytes could not be collected for unmarshaling.","triggerScenarios":"POSTing to the join endpoint where io.ReadAll on the opened 'config-block' file part fails — connection reset mid-read, body truncated by MaxBytesReader, or disk/network I/O errors on the server stream.","commonSituations":"Very large genesis blocks hitting MaxRequestBodySize limits; unstable network between client and orderer; reverse proxy (nginx/envoy) buffering limits cutting the upload; client crash during upload.","solutions":["Re-send the request ensuring the full file uploads without interruption","Increase h.config.MaxRequestBodySize (General.MaxRequestBodySize in orderer config) if the block exceeds the limit","Check and raise proxy/client timeouts and buffering limits for large uploads","Retry on flaky network links and verify file integrity (size/checksum) client-side before upload"],"exampleFix":"# before: orderer rejects large genesis blocks\n# General.MaxRequestBodySize: 10MB\n# after\n# orderer.yaml\nGeneral:\n  MaxRequestBodySize: 100MB","handlingStrategy":"validation","validationCode":"blockBytes, err := os.ReadFile(blockPath)\nif err != nil || len(blockBytes) == 0 {\n    return fmt.Errorf(\"cannot read block file locally: %w\", err)\n}\nif int64(len(blockBytes)) > maxRequestBodySize {\n    return fmt.Errorf(\"block size %d exceeds server MaxRequestBodySize %d\", len(blockBytes), maxRequestBodySize)\n}","typeGuard":null,"tryCatchPattern":"if err != nil {\n    if errors.Is(err, io.ErrUnexpectedEOF) {\n        // truncated upload: retry with fresh connection\n        return retryUpload(blockBytes)\n    }\n    return err\n}","preventionTips":["Verify block file size is below the orderer's MaxRequestBodySize","Retry uploads on unstable networks","Raise proxy client-body size limits (e.g. nginx client_max_body_size)"],"tags":["http","fabric","multipart-form","io"],"backgroundTag":"request-body-read-failed","analyzedSha":"2736b63f8fd5932511d56fe68b7039d15977f7f6","analyzedAt":"2026-09-04T08:52:36.465Z","contentChangedAt":"2026-09-04T08:52:36.465Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}