{"record":{"id":"8e129a0f5c603952","repo":"AlexxIT/go2rtc","slug":"wyze-invalid-url-w","errorCode":null,"errorMessage":"wyze: invalid URL: %w","messagePattern":"wyze: invalid URL: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/wyze/client.go","lineNumber":83,"sourceCode":"\tcloseMu sync.Mutex\n\n\thasAudio    bool\n\thasIntercom bool\n\n\taudioCodecID    byte\n\taudioSampleRate uint32\n\taudioChannels   uint8\n}\n\ntype AuthResponse struct {\n\tConnectionRes string         `json:\"connectionRes\"`\n\tCameraInfo    map[string]any `json:\"cameraInfo\"`\n}\n\nfunc Dial(rawURL string) (*Client, error) {\n\tu, err := url.Parse(rawURL)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"wyze: invalid URL: %w\", err)\n\t}\n\n\tquery := u.Query()\n\n\tif query.Get(\"dtls\") != \"true\" {\n\t\treturn nil, fmt.Errorf(\"wyze: only DTLS cameras are supported\")\n\t}\n\n\tc := &Client{\n\t\thost:    u.Host,\n\t\tuid:     query.Get(\"uid\"),\n\t\tenr:     query.Get(\"enr\"),\n\t\tmac:     query.Get(\"mac\"),\n\t\tmodel:   query.Get(\"model\"),\n\t\tverbose: query.Get(\"verbose\") == \"true\",\n\t}\n\n\tc.authKey = string(dtls.CalculateAuthKey(c.enr, c.mac))","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/AlexxIT/go2rtc/blob/c245815e75e2a5fd60b4290f12bfc04e55a984d3/pkg/wyze/client.go#L65-L101","documentation":"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.","triggerScenarios":"Calling wyze.Dial(rawURL) with a malformed URL string: missing scheme, invalid percent-encoding, control characters, or a garbled config value reaching the parser.","commonSituations":"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.","solutions":["Print/inspect the raw URL passed to Dial and validate it with net/url.Parse locally","Ensure the URL has the wyze:// scheme and required query params (uid, enr, dtls=true)","URL-encode credential values (enr/token) that contain special characters","Fix quoting/interpolation in the YAML/JSON config that builds the URL","Compare against a known-good wyze:// URL from a working setup"],"exampleFix":"// before\nurl := \"wyze://[bad uid..?dtls=true&enr=\" + enr // unencoded, unparseable\n// after\nu := \"wyze://\" + host + \"/?dtls=true&uid=\" + url.QueryEscape(uid) + \"&enr=\" + url.QueryEscape(enr)\nclient, err := wyze.Dial(u)","handlingStrategy":"validation","validationCode":"// Go: validate the URL before Dial\nu, err := url.Parse(rawURL)\nif err != nil || u.Scheme != \"wyze\" || u.Host == \"\" {\n    return fmt.Errorf(\"malformed wyze URL: %v\", rawURL)\n}","typeGuard":"func validWyzeURL(raw string) bool { u, err := url.Parse(raw); return err == nil && u.Scheme == \"wyze\" && u.Host != \"\" }","tryCatchPattern":"client, err := wyze.Dial(rawURL)\nif err != nil {\n    return fmt.Errorf(\"check wyze URL in config (%s): %w\", rawURL, err)\n}","preventionTips":["URL-encode dynamic values (uid, enr) inserted into wyze:// URLs","Never interpolate empty/nil config values into URLs","Validate URLs at config-load time, before Dial","Keep scheme and required params (uid, enr, dtls) in a helper builder"],"tags":["wyze","url","config","parsing"],"backgroundTag":"invalid-url","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"}