{"record":{"id":"2cf9a857c5324a76","repo":"hyperledger/fabric","slug":"cannot-parse-mime-media-type","errorCode":null,"errorMessage":"cannot parse Mime media type","messagePattern":"cannot parse Mime media type","errorType":"http","errorClass":null,"httpStatus":400,"severity":"warning","filePath":"orderer/common/channelparticipation/restapi.go","lineNumber":360,"sourceCode":"\t}\n\n\tresp.Header().Set(\"Cache-Control\", \"no-store\")\n\tresp.Header().Set(\"Content-Type\", \"application/octet-stream\")\n\th.sendResponseBlock(resp, blockBytes)\n}\n\n// Join a channel.\n// Expect multipart/form-data.\nfunc (h *HTTPHandler) serveJoin(resp http.ResponseWriter, req *http.Request) {\n\t_, err := negotiateContentType(req) // Only application/json responses for now\n\tif err != nil {\n\t\th.sendResponseJsonError(resp, http.StatusNotAcceptable, err)\n\t\treturn\n\t}\n\n\t_, params, err := mime.ParseMediaType(req.Header.Get(\"Content-Type\"))\n\tif err != nil {\n\t\th.sendResponseJsonError(resp, http.StatusBadRequest, errors.Wrap(err, \"cannot parse Mime media type\"))\n\t\treturn\n\t}\n\n\tblock := h.multipartFormDataBodyToBlock(params, req, resp)\n\tif block == nil {\n\t\treturn\n\t}\n\n\tchannelID, err := ValidateJoinBlock(block)\n\tif err != nil {\n\t\th.sendResponseJsonError(resp, http.StatusBadRequest, errors.WithMessage(err, \"invalid join block\"))\n\t\treturn\n\t}\n\n\tinfo, err := h.registrar.JoinChannel(channelID, block)\n\tif err != nil {\n\t\th.sendJoinError(err, resp)\n\t\treturn","sourceCodeStart":342,"sourceCodeEnd":378,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/orderer/common/channelparticipation/restapi.go#L342-L378","documentation":"serveJoin parses the request's Content-Type header with mime.ParseMediaType to confirm it is multipart/form-data and extract the boundary. If the header is missing, malformed, or not parseable, the request is rejected with 400 and this wrapped error.","triggerScenarios":"POST to the participation join endpoint with a Content-Type that isn't parseable multipart/form-data (missing header, typo like 'multipart/form-data' without boundary=, or wrong type such as application/octet-stream).","commonSituations":"Hand-rolled curl calls omitting -F (which sets multipart) and instead using --data-binary; HTTP clients setting Content-Type manually without the boundary parameter; proxies stripping or rewriting the Content-Type header.","solutions":["Use multipart/form-data with an explicit boundary: Content-Type: multipart/form-data; boundary=<boundary>","Send the request with curl -F or an HTTP client multipart API so Content-Type and boundary are set automatically","Verify no proxy/middleware strips or rewrites the Content-Type header","Check the wrapped inner error to identify the exact header syntax problem"],"exampleFix":"// before\ncurl -X POST --data-binary @config.block http://orderer/participation/v2/channels\n// after\ncurl -X POST -F 'config-block=@config.block' http://orderer/participation/v2/channels","handlingStrategy":"validation","validationCode":"ct := req.Header.Get(\"Content-Type\")\nmt, params, err := mime.ParseMediaType(ct)\nif err != nil || mt != \"multipart/form-data\" || params[\"boundary\"] == \"\" {\n\treturn errors.New(\"use multipart/form-data with a boundary, e.g. curl -F\")\n}","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"cannot parse Mime media type\") {\n\t// fix client: send multipart/form-data; boundary=... and retry\n}","preventionTips":["Use curl -F or an HTTP client multipart API so Content-Type is generated correctly","Never set Content-Type manually for multipart uploads without including boundary=","Check proxies/gateways do not rewrite Content-Type headers","Test the join call with curl before wiring it into automation"],"tags":["http","content-type","multipart","orderer"],"backgroundTag":"invalid-content-type","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"}