AlexxIT/go2rtc · error

tuya: wrong query params

Error message

tuya: wrong query params

What it means

Tuya Dial parameter guard: the query string provides neither a complete Smart-API credential set (device_id + email + password) nor a complete Cloud-API set (device_id + uid + client_id + client_secret). At least one full set is required to authenticate, so the source URL's credentials are incomplete.

Solutions

  1. Add the missing Smart API params (email, password, device_id) or Cloud params (uid, client_id, client_secret)
  2. Check query param names for typos
  3. Ensure the device_id param is present — it is required by both modes
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at pkg/tuya/client.go:82 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/50d820897f1fbc23. Report an issue: GitHub.

Appendix: source

Thrown at pkg/tuya/client.go:82

	uid := query.Get("uid")
	clientId := query.Get("client_id")
	clientSecret := query.Get("client_secret")

	// Shared params
	deviceId := query.Get("device_id")

	// Stream params
	streamResolution := query.Get("resolution")

	useSmartApi := deviceId != "" && email != "" && password != ""
	useCloudApi := deviceId != "" && uid != "" && clientId != "" && clientSecret != ""

	if streamResolution == "" || (streamResolution != "hd" && streamResolution != "sd") {
		streamResolution = "hd"
	}

	if !useSmartApi && !useCloudApi {
		return nil, errors.New("tuya: wrong query params")
	}

	client := &Client{
		handlers: make(map[uint32]func(*rtp.Packet)),
	}

	if useSmartApi {
		if client.api, err = NewTuyaSmartApiClient(nil, u.Hostname(), email, password, deviceId); err != nil {
			return nil, fmt.Errorf("tuya: %w", err)
		}
	} else {
		if client.api, err = NewTuyaCloudApiClient(u.Hostname(), uid, deviceId, clientId, clientSecret); err != nil {
			return nil, fmt.Errorf("tuya: %w", err)
		}
	}

	if err := client.api.Init(); err != nil {
		return nil, fmt.Errorf("tuya: %w", err)

View on GitHub (pinned to c245815e75)