AlexxIT/go2rtc · warning
no auth
Error message
no auth
What it means
A GET request reached the roborock API handler before any login was performed. Auth.UserData is nil because no prior POST populated the session, so the handler rejects the request with 'no auth' and HTTP 404.
Solutions
- POST username/password first to authenticate, then issue the GET request
- Persist or re-establish the session after server restarts
- Return 401 instead of 404 and include a hint to authenticate first
Example fix
// before
case "GET":
if Auth.UserData == nil {
http.Error(w, "no auth", http.StatusNotFound)
return
}
// after
case "GET":
if Auth.UserData == nil {
http.Error(w, "not authenticated: POST username and password first", http.StatusUnauthorized)
return
} Defensive patterns
Strategy: validation
Validate before calling
if Auth.UserData == nil {
// redirect to login or return 401 before issuing GET requests
} Type guard
func isAuthenticated(a *AuthState) bool { return a != nil && a.UserData != nil && a.UserData.Token != "" } Prevention
- Always POST credentials before issuing GET device requests
- Persist session state or re-login after server restarts
- Have clients check an auth status endpoint before calling GET
- Use 401 with a clear message so clients know to authenticate
When it happens
Trigger: GET to the roborock API endpoint with no preceding successful POST /login in the same process; server restarted (Auth is in-memory) so UserData was reset to nil.
Common situations: Client hits GET before authenticating; server process restarted clearing in-memory session state; session cookie/token not sent by the client.
Related errors
- milesone: authentication failed:
- loginResp.ErrorMsg
- tuya:
- multitrans: expected 401, got
- multitrans: auth failed
AI-assisted analysis of AlexxIT/go2rtc@c245815e75 (2026-09-07).
Data as JSON: /api/errors/090a84ea39ef6f75.
Report an issue: GitHub.
Appendix: source
Thrown at internal/roborock/roborock.go:30
func Init() {
streams.HandleFunc("roborock", func(source string) (core.Producer, error) {
return roborock.Dial(source)
})
api.HandleFunc("api/roborock", apiHandle)
}
var Auth struct {
UserData *roborock.UserInfo `json:"user_data"`
BaseURL string `json:"base_url"`
}
func apiHandle(w http.ResponseWriter, r *http.Request) {
switch r.Method {
case "GET":
if Auth.UserData == nil {
http.Error(w, "no auth", http.StatusNotFound)
return
}
case "POST":
if err := r.ParseMultipartForm(1024); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
username := r.Form.Get("username")
password := r.Form.Get("password")
if username == "" || password == "" {
http.Error(w, "empty username or password", http.StatusBadRequest)
return
}
base, err := roborock.GetBaseURL(username)
if err != nil {View on GitHub (pinned to c245815e75)