AlexxIT/go2rtc · error

${appInfoResponse.Msg}

Error message

${appInfoResponse.Msg}

What it means

GetAppInfo returns this error when the Tuya Smart API responds with Success=false; the server-side message from AppInfoResponse.Msg is surfaced verbatim via errors.New. It means the HTTP request completed but the Tuya cloud rejected or failed the app-info request (bad credentials, bad params, or cloud-side issue). The library throws it to propagate the API's own error text to the caller.

Solutions

  1. Inspect the returned Msg text for the concrete Tuya API reason (e.g. token expired) and fix that root cause first.
  2. Re-initialize the client/token (initToken / login) before retrying GetAppInfo.
  3. Verify the Tuya region/endpoint and credentials (access key, app account) in your configuration.
  4. Add retry with backoff for transient cloud errors, and fail fast on authentication-type messages.
  5. Log the full response body on failure to capture error codes beyond Msg.

Example fix

// before
resp, err := client.GetAppInfo()
if err != nil {
    log.Fatal(err) // bare "Msg" text, no context
}
// after
resp, err := client.GetAppInfo()
if err != nil {
    log.Fatalf("get app info failed: %v", err) // wrap with context
}
Defensive patterns

Strategy: try-catch

Validate before calling

if client == nil || client token expired { reinitialize client before calling GetAppInfo() }

Try / catch

resp, err := client.GetAppInfo()
if err != nil {
    switch {
    case strings.Contains(err.Error(), "token"):
        // re-authenticate and retry once
    default:
        return fmt.Errorf("tuya app info: %w", err)
    }
}

Prevention

When it happens

Trigger: Calling TuyaSmartApiClient.GetAppInfo() when the Tuya API returns a JSON body whose Success field is false, with the human-readable reason in Msg.

Common situations: Expired or invalid Tuya credentials/access tokens; wrong region/API endpoint configured; Tuya cloud outage or rate limiting; device/account unlinked so app info is unavailable.

Related errors


AI-assisted analysis of AlexxIT/go2rtc@c245815e75 (2026-09-07). Data as JSON: /api/errors/0fd437c37907c35f. Report an issue: GitHub.

Appendix: source

Thrown at pkg/tuya/smart_api.go:342

func (c *TuyaSmartApiClient) GetStreamUrl(streamType string) (streamUrl string, err error) {
	return "", errors.New("not supported")
}

func (c *TuyaSmartApiClient) GetAppInfo() (*AppInfoResponse, error) {
	url := fmt.Sprintf("https://%s/api/customized/web/app/info", c.baseUrl)

	body, err := c.request("POST", url, nil)
	if err != nil {
		return nil, err
	}

	var appInfoResponse AppInfoResponse
	if err := json.Unmarshal(body, &appInfoResponse); err != nil {
		return nil, err
	}

	if !appInfoResponse.Success {
		return nil, errors.New(appInfoResponse.Msg)
	}

	return &appInfoResponse, nil
}

func (c *TuyaSmartApiClient) GetHomeList() (*HomeListResponse, error) {
	url := fmt.Sprintf("https://%s/api/new/common/homeList", c.baseUrl)

	body, err := c.request("POST", url, nil)
	if err != nil {
		return nil, err
	}

	var homeListResponse HomeListResponse
	if err := json.Unmarshal(body, &homeListResponse); err != nil {
		return nil, err
	}

View on GitHub (pinned to c245815e75)