AlexxIT/go2rtc · error
email, password and region are required
Error message
email, password and region are required
What it means
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.
Solutions
- Supply all three query parameters: region, email, password
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at internal/tuya/tuya.go:33 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of AlexxIT/go2rtc@c245815e75 (2026-09-07).
Data as JSON: /api/errors/c68fb462e3811b72.
Report an issue: GitHub.
Appendix: source
Thrown at internal/tuya/tuya.go:33
"github.com/AlexxIT/go2rtc/pkg/tuya"
)
func Init() {
streams.HandleFunc("tuya", func(source string) (core.Producer, error) {
return tuya.Dial(source)
})
api.HandleFunc("api/tuya", apiTuya)
}
func apiTuya(w http.ResponseWriter, r *http.Request) {
query := r.URL.Query()
region := query.Get("region")
email := query.Get("email")
password := query.Get("password")
if email == "" || password == "" || region == "" {
http.Error(w, "email, password and region are required", http.StatusBadRequest)
return
}
var tuyaRegion *tuya.Region
for _, r := range tuya.AvailableRegions {
if r.Host == region {
tuyaRegion = &r
break
}
}
if tuyaRegion == nil {
http.Error(w, fmt.Sprintf("invalid region: %s", region), http.StatusBadRequest)
return
}
httpClient := tuya.CreateHTTPClientWithSession()
View on GitHub (pinned to c245815e75)