{"record":{"id":"7d955c2607bc17d6","repo":"AlexxIT/go2rtc","slug":"roomlistresponse-msg","errorCode":null,"errorMessage":"${roomListResponse.Msg}","messagePattern":"\\$\\{roomListResponse\\.Msg\\}","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/tuya/smart_api.go","lineNumber":406,"sourceCode":"func (c *TuyaSmartApiClient) GetRoomList(homeId string) (*RoomListResponse, error) {\n\turl := fmt.Sprintf(\"https://%s/api/new/common/roomList\", c.baseUrl)\n\n\tdata := RoomListRequest{\n\t\tHomeId: homeId,\n\t}\n\n\tbody, err := c.request(\"POST\", url, data)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar roomListResponse RoomListResponse\n\tif err := json.Unmarshal(body, &roomListResponse); err != nil {\n\t\treturn nil, err\n\t}\n\n\tif !roomListResponse.Success {\n\t\treturn nil, errors.New(roomListResponse.Msg)\n\t}\n\n\treturn &roomListResponse, nil\n}\n\nfunc (c *TuyaSmartApiClient) initToken() error {\n\ttokenUrl := fmt.Sprintf(\"https://%s/api/login/token\", c.baseUrl)\n\n\ttokenReq := LoginTokenRequest{\n\t\tCountryCode: c.countryCode,\n\t\tUsername:    c.email,\n\t\tIsUid:       false,\n\t}\n\n\tbody, err := c.request(\"POST\", tokenUrl, tokenReq)\n\tif err != nil {\n\t\treturn err\n\t}","sourceCodeStart":388,"sourceCodeEnd":424,"githubUrl":"https://github.com/AlexxIT/go2rtc/blob/c245815e75e2a5fd60b4290f12bfc04e55a984d3/pkg/tuya/smart_api.go#L388-L424","documentation":"GetRoomList returns this error when the Tuya API responds with Success=false; roomListResponse.Msg is wrapped directly via errors.New. The request reached the cloud but the room listing for the given homeId was rejected. The library forwards the server's own message.","triggerScenarios":"Calling TuyaSmartApiClient.GetRoomList(homeId) with a homeId whose API response carries Success=false — e.g. nonexistent homeId, revoked access, or expired token.","commonSituations":"Passing a homeId from a different account/region; home deleted after listing; token expiry mid-session; Tuya cloud error.","solutions":["Check Msg for 'not exist'/'permission' wording and validate the homeId against GetHomeList results.","Re-authenticate (initToken/login) and retry.","Verify homeId belongs to the logged-in account and region.","Distinguish permanent errors (bad homeId) from transient ones before retrying.","Log full response body on failure."],"exampleFix":"// before\nrooms, err := client.GetRoomList(homeID)\nif err != nil {\n    return err\n}\n// after\nrooms, err := client.GetRoomList(homeID)\nif err != nil {\n    return fmt.Errorf(\"get rooms for home %s: %w\", homeID, err)\n}","handlingStrategy":"validation","validationCode":"homes, _ := client.GetHomeList()\nvalid := false\nfor _, h := range homes.Result {\n    if h.HomeID == homeID { valid = true }\n}\nif !valid { return fmt.Errorf(\"home %s not in account\", homeID) }\nrooms, err := client.GetRoomList(homeID)","typeGuard":null,"tryCatchPattern":"rooms, err := client.GetRoomList(homeID)\nif err != nil {\n    return fmt.Errorf(\"rooms for home %s: %w\", homeID, err)\n}","preventionTips":["Validate homeId against GetHomeList before calling","Re-authenticate when Msg indicates token problems","Avoid caching homeIds across account changes","Log full responses on failure"],"tags":["api","tuya","http-error-response"],"backgroundTag":"api-error-response","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"}