{"record":{"id":"9e71892875d9ab98","repo":"AlexxIT/go2rtc","slug":"empty-username-or-password","errorCode":null,"errorMessage":"empty username or password","messagePattern":"empty username or password","errorType":"http","errorClass":null,"httpStatus":400,"severity":"warning","filePath":"internal/roborock/roborock.go","lineNumber":43,"sourceCode":"\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 {\n\t\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\n\t\tAuth.BaseURL = base\n\t\tAuth.UserData = ui\n","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/AlexxIT/go2rtc/blob/c245815e75e2a5fd60b4290f12bfc04e55a984d3/internal/roborock/roborock.go#L25-L61","documentation":"The handler requires both username and password form fields, but at least one was empty or missing from the multipart form. It rejects the request with HTTP 400 and this static message before any network calls are made.","triggerScenarios":"POST to the roborock endpoint where r.Form.Get(\"username\") or r.Form.Get(\"password\") returns \"\" - fields absent, misspelled, or sent with empty values.","commonSituations":"Form field name mismatch (user vs username); frontend submitted with blank inputs; client only sent one of the two fields.","solutions":["Include both username and password fields with non-empty values in the multipart form","Fix field naming on the client to match the handler","Add client-side required-field validation before submitting"],"exampleFix":"// before\ncurl -X POST http://host/api -F 'username=u'\n// after\ncurl -X POST http://host/api -F 'username=u' -F 'password=p'","handlingStrategy":"validation","validationCode":"if r.Form.Get(\"username\") == \"\" || r.Form.Get(\"password\") == \"\" {\n\t// return 400 with 'empty username or password' before any network call\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always send both username and password fields","Use required attributes on form inputs","Keep field names consistent between client and server","Trim whitespace-only values before submission"],"tags":["go","http","validation","form"],"backgroundTag":"empty-required-field","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"}