{"record":{"id":"866e339bd367d300","repo":"AlexxIT/go2rtc","slug":"err-error-866e33","errorCode":null,"errorMessage":"err.Error()","messagePattern":"err\\.Error\\(\\)","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"internal/roborock/roborock.go","lineNumber":36,"sourceCode":"\tapi.HandleFunc(\"api/roborock\", apiHandle)\n}\n\nvar Auth struct {\n\tUserData *roborock.UserInfo `json:\"user_data\"`\n\tBaseURL  string             `json:\"base_url\"`\n}\n\nfunc apiHandle(w http.ResponseWriter, r *http.Request) {\n\tswitch r.Method {\n\tcase \"GET\":\n\t\tif Auth.UserData == nil {\n\t\t\thttp.Error(w, \"no auth\", http.StatusNotFound)\n\t\t\treturn\n\t\t}\n\n\tcase \"POST\":\n\t\tif err := r.ParseMultipartForm(1024); err != nil {\n\t\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\n\t\tusername := r.Form.Get(\"username\")\n\t\tpassword := r.Form.Get(\"password\")\n\t\tif username == \"\" || password == \"\" {\n\t\t\thttp.Error(w, \"empty username or password\", http.StatusBadRequest)\n\t\t\treturn\n\t\t}\n\n\t\tbase, err := roborock.GetBaseURL(username)\n\t\tif err != nil {\n\t\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\n\t\tui, err := roborock.Login(base, username, password)\n\t\tif err != nil {","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/AlexxIT/go2rtc/blob/c245815e75e2a5fd60b4290f12bfc04e55a984d3/internal/roborock/roborock.go#L18-L54","documentation":"Parsing the multipart request body failed in r.ParseMultipartForm(1024). This happens when the POST body is not valid multipart/form-data matching the Content-Type boundary, or the body exceeds the 1KB maxMemory buffer constraints in a malformed way; the raw parse error is relayed with HTTP 500.","triggerScenarios":"POST to the roborock endpoint with a non-multipart Content-Type (e.g. application/x-www-form-urlencoded or JSON), a malformed boundary, or a truncated request body.","commonSituations":"Client sent JSON instead of multipart form data; curl default content type used; proxy truncated the body; forgot enctype='multipart/form-data' in an HTML form.","solutions":["Send the request as multipart/form-data with fields username and password","Set the correct Content-Type header / form enctype","Fall back to r.ParseForm for urlencoded requests"],"exampleFix":"// before\ncurl -X POST http://host/api -H 'Content-Type: application/json' -d '{\"username\":\"u\",\"password\":\"p\"}'\n// after\ncurl -X POST http://host/api -F 'username=u' -F 'password=p'","handlingStrategy":"validation","validationCode":"if !strings.HasPrefix(r.Header.Get(\"Content-Type\"), \"multipart/form-data\") {\n\t// return 415 asking for multipart/form-data before parsing\n}","typeGuard":null,"tryCatchPattern":"if err := r.ParseMultipartForm(1024); err != nil {\n\t// check content type first, then return 400 with a hint to use -F / multipart\n}","preventionTips":["Send POST bodies as multipart/form-data (curl -F, form enctype)","Verify the Content-Type header before posting","Avoid proxies that truncate request bodies","Read the handler's expected form format before integrating"],"tags":["go","http","multipart","request"],"backgroundTag":"http-request-failed","analyzedSha":"c245815e75e2a5fd60b4290f12bfc04e55a984d3","analyzedAt":"2026-09-07T11:47:02.965Z","contentChangedAt":"2026-09-07T11:47:02.965Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}