{"record":{"id":"c68fb462e3811b72","repo":"AlexxIT/go2rtc","slug":"email-password-and-region-are-required","errorCode":null,"errorMessage":"email, password and region are required","messagePattern":"email, password and region are required","errorType":"http","errorClass":null,"httpStatus":400,"severity":"error","filePath":"internal/tuya/tuya.go","lineNumber":33,"sourceCode":"\t\"github.com/AlexxIT/go2rtc/pkg/tuya\"\n)\n\nfunc Init() {\n\tstreams.HandleFunc(\"tuya\", func(source string) (core.Producer, error) {\n\t\treturn tuya.Dial(source)\n\t})\n\n\tapi.HandleFunc(\"api/tuya\", apiTuya)\n}\n\nfunc apiTuya(w http.ResponseWriter, r *http.Request) {\n\tquery := r.URL.Query()\n\tregion := query.Get(\"region\")\n\temail := query.Get(\"email\")\n\tpassword := query.Get(\"password\")\n\n\tif email == \"\" || password == \"\" || region == \"\" {\n\t\thttp.Error(w, \"email, password and region are required\", http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tvar tuyaRegion *tuya.Region\n\tfor _, r := range tuya.AvailableRegions {\n\t\tif r.Host == region {\n\t\t\ttuyaRegion = &r\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif tuyaRegion == nil {\n\t\thttp.Error(w, fmt.Sprintf(\"invalid region: %s\", region), http.StatusBadRequest)\n\t\treturn\n\t}\n\n\thttpClient := tuya.CreateHTTPClientWithSession()\n","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/AlexxIT/go2rtc/blob/c245815e75e2a5fd60b4290f12bfc04e55a984d3/internal/tuya/tuya.go#L15-L51","documentation":"apiTuya validates query parameters before doing anything: region, email and password must all be non-empty. If any is missing the request is rejected with 400. A generic required-field guard on the Tuya API endpoint.","triggerScenarios":"Thrown at internal/tuya/tuya.go:33 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Supply all three query parameters: region, email, password"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}