{"record":{"id":"2a7e8b45aa808ad0","repo":"AlexxIT/go2rtc","slug":"allocresponse-msg","errorCode":null,"errorMessage":"${allocResponse.Msg}","messagePattern":"\\$\\{allocResponse\\.Msg\\}","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/tuya/cloud_api.go","lineNumber":150,"sourceCode":"\turl := fmt.Sprintf(\"https://%s/v1.0/devices/%s/stream/actions/allocate\", c.baseUrl, c.deviceId)\n\n\trequest := &AllocateRequest{\n\t\tType: streamType,\n\t}\n\n\tbody, err := c.request(\"POST\", url, request)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tvar allocResponse AllocateResponse\n\terr = json.Unmarshal(body, &allocResponse)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tif !allocResponse.Success {\n\t\treturn \"\", errors.New(allocResponse.Msg)\n\t}\n\n\treturn allocResponse.Result.URL, nil\n}\n\nfunc (c *TuyaCloudApiClient) initToken() (err error) {\n\tif c.refreshingToken {\n\t\treturn nil\n\t}\n\n\tnow := time.Now().Unix()\n\tif (c.expireTime - 60) > now {\n\t\treturn nil\n\t}\n\n\tc.refreshingToken = true\n\n\turl := fmt.Sprintf(\"https://%s/v1.0/token?grant_type=1\", c.baseUrl)","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/AlexxIT/go2rtc/blob/c245815e75e2a5fd60b4290f12bfc04e55a984d3/pkg/tuya/cloud_api.go#L132-L168","documentation":"Tuya Cloud API GetStreamUrl guard: the /v1.0/devices/{id}/stream/actions/allocate call transported fine, but the AllocateResponse reports Success=false and its server-provided Msg becomes the error. The cloud refused to allocate a WebRTC stream for the device — permissions, plan limits, or device state per Msg.","triggerScenarios":"Thrown at pkg/tuya/cloud_api.go:150 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Act on the appended Msg (e.g. device offline, no permission)","Verify client_id/client_secret and the device belongs to the account","Retry after the cloud/device recovers; allocation can be transiently unavailable"],"exampleFix":null,"handlingStrategy":"try-catch","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"}