AlexxIT/go2rtc · error

wyze: invalid URL

Error message

wyze: invalid URL: %w

What it means

Returned by the public Dial() constructor for the Wyze client when the raw URL cannot be parsed by url.Parse. Dial expects a wyze:// URL with query parameters (uid, enr, dtls, etc.); an unparseable URL means the client cannot even extract host or parameters and construction aborts with this wrapped error.

Solutions

  1. Print/inspect the raw URL passed to Dial and validate it with net/url.Parse locally
  2. Ensure the URL has the wyze:// scheme and required query params (uid, enr, dtls=true)
  3. URL-encode credential values (enr/token) that contain special characters
  4. Fix quoting/interpolation in the YAML/JSON config that builds the URL
  5. Compare against a known-good wyze:// URL from a working setup

Example fix

// before
url := "wyze://[bad uid..?dtls=true&enr=" + enr // unencoded, unparseable
// after
u := "wyze://" + host + "/?dtls=true&uid=" + url.QueryEscape(uid) + "&enr=" + url.QueryEscape(enr)
client, err := wyze.Dial(u)
Defensive patterns

Strategy: validation

Validate before calling

// Go: validate the URL before Dial
u, err := url.Parse(rawURL)
if err != nil || u.Scheme != "wyze" || u.Host == "" {
    return fmt.Errorf("malformed wyze URL: %v", rawURL)
}

Type guard

func validWyzeURL(raw string) bool { u, err := url.Parse(raw); return err == nil && u.Scheme == "wyze" && u.Host != "" }

Try / catch

client, err := wyze.Dial(rawURL)
if err != nil {
    return fmt.Errorf("check wyze URL in config (%s): %w", rawURL, err)
}

Prevention

When it happens

Trigger: Calling wyze.Dial(rawURL) with a malformed URL string: missing scheme, invalid percent-encoding, control characters, or a garbled config value reaching the parser.

Common situations: Hand-edited go2rtc config with a broken wyze URL; credentials/uid containing characters that were not URL-encoded; truncated URL copied from elsewhere; automation that interpolates empty strings into the URL.

Understand the failure class

Background: "Invalid URL" / "URL cannot be empty": fix the malformed or missing URL behind request-construction failures — this error's family across 50 libraries.

Related errors


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

Appendix: source

Thrown at pkg/wyze/client.go:83

	closeMu sync.Mutex

	hasAudio    bool
	hasIntercom bool

	audioCodecID    byte
	audioSampleRate uint32
	audioChannels   uint8
}

type AuthResponse struct {
	ConnectionRes string         `json:"connectionRes"`
	CameraInfo    map[string]any `json:"cameraInfo"`
}

func Dial(rawURL string) (*Client, error) {
	u, err := url.Parse(rawURL)
	if err != nil {
		return nil, fmt.Errorf("wyze: invalid URL: %w", err)
	}

	query := u.Query()

	if query.Get("dtls") != "true" {
		return nil, fmt.Errorf("wyze: only DTLS cameras are supported")
	}

	c := &Client{
		host:    u.Host,
		uid:     query.Get("uid"),
		enr:     query.Get("enr"),
		mac:     query.Get("mac"),
		model:   query.Get("model"),
		verbose: query.Get("verbose") == "true",
	}

	c.authKey = string(dtls.CalculateAuthKey(c.enr, c.mac))

View on GitHub (pinned to c245815e75)