{"record":{"id":"5f9bc25ce562aaa6","repo":"AlexxIT/go2rtc","slug":"ring-wrong-query","errorCode":null,"errorMessage":"ring: wrong query","messagePattern":"ring: wrong query","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/ring/client.go","lineNumber":39,"sourceCode":"\tdialogID  string\n\tconnected core.Waiter\n\tclosed    bool\n}\n\nfunc Dial(rawURL string) (*Client, error) {\n\tu, err := url.Parse(rawURL)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tquery := u.Query()\n\tencodedToken := query.Get(\"refresh_token\")\n\tcameraID := query.Get(\"camera_id\")\n\tdeviceID := query.Get(\"device_id\")\n\t_, isSnapshot := query[\"snapshot\"]\n\n\tif encodedToken == \"\" || deviceID == \"\" || cameraID == \"\" {\n\t\treturn nil, errors.New(\"ring: wrong query\")\n\t}\n\n\tclient := &Client{\n\t\tdialogID: uuid.NewString(),\n\t}\n\n\tclient.cameraID, err = strconv.Atoi(cameraID)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"ring: invalid camera_id: %w\", err)\n\t}\n\n\trefreshToken, err := url.QueryUnescape(encodedToken)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"ring: invalid refresh token encoding: %w\", err)\n\t}\n\n\tclient.api, err = NewRestClient(RefreshTokenAuth{RefreshToken: refreshToken}, nil)\n\tif err != nil {","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/AlexxIT/go2rtc/blob/c245815e75e2a5fd60b4290f12bfc04e55a984d3/pkg/ring/client.go#L21-L57","documentation":"Ring's Dial parses the connection query parameters and requires refresh_token, camera_id and device_id. If any of these is missing or empty it throws \"ring: wrong query\" before attempting any connection.","triggerScenarios":"Dialing a ring camera stream with a query string missing refresh_token, device_id, or camera_id — e.g. \"?refresh_token=abc&device_id=xyz\" (no camera_id) or an empty query entirely.","commonSituations":"Building the connection URL by hand and omitting a parameter; credentials/config where the camera_id was never filled in; snapshot mode URLs still requiring the base trio of params.","solutions":["Include all three query params: refresh_token, camera_id and device_id","Verify the refresh token is non-empty (a fresh valid Ring refresh token)","URL-encode the query string properly so params are not dropped"],"exampleFix":"// before\nconn.Dial(\"ring://ring.com?device_id=abc\")\n// after\nconn.Dial(\"ring://ring.com?refresh_token=RT&camera_id=CAM1&device_id=abc\")","handlingStrategy":"validation","validationCode":"u, _ := url.Parse(connStr)\nq := u.Query()\nfor _, k := range []string{\"refresh_token\", \"camera_id\", \"device_id\"} {\n    if q.Get(k) == \"\" {\n        return fmt.Errorf(\"ring query missing %s\", k)\n    }\n}","typeGuard":null,"tryCatchPattern":"client, err := Dial(ctx, query)\nif err != nil && err.Error() == \"ring: wrong query\" {\n    return fmt.Errorf(\"ring connection string malformed: %w\", err)\n}","preventionTips":["Build the query with url.Values so no param is silently dropped","Validate connection strings at config load time","Log which of the three params is missing in your own pre-check"],"tags":["query-params","validation","ring"],"backgroundTag":"missing-required-argument","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"}