{"record":{"id":"431006f78cecb482","repo":"AlexxIT/go2rtc","slug":"ring-invalid-camera-id-w","errorCode":null,"errorMessage":"ring: invalid camera_id: %w","messagePattern":"ring: invalid camera_id: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/ring/client.go","lineNumber":48,"sourceCode":"\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 {\n\t\treturn nil, err\n\t}\n\n\t// Snapshot Flow\n\tif isSnapshot {\n\t\tclient.prod = NewSnapshotProducer(client.api, client.cameraID)\n\t\treturn client, nil\n\t}\n","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/AlexxIT/go2rtc/blob/c245815e75e2a5fd60b4290f12bfc04e55a984d3/pkg/ring/client.go#L30-L66","documentation":"Dial() builds a ring camera Client and converts the cameraID string to an int with strconv.Atoi. When the provided camera_id is not a valid integer (or empty), Atoi fails and Dial wraps the parse error with this message. The library refuses to construct a Client with an unusable camera identifier rather than failing later at request time.","triggerScenarios":"Calling ring.Dial with a camera_id that is empty, contains letters/symbols/whitespace, has a URL prefix, or is a non-numeric identifier (e.g. a device UUID instead of the numeric camera ID).","commonSituations":"Passing a Ring device name or UUID copied from the web UI instead of the numeric camera ID; an empty/unset config value; trimming issues leaving a trailing newline or space in the ID from an env var or config file.","solutions":["Print the input cameraID and confirm it is purely digits (strconv.Atoi-compatible).","Look up the correct numeric camera ID for the device and pass that instead of a name/UUID.","Trim whitespace/newlines from the value before passing it in.","Fix the config file or environment variable that supplies the camera_id so it is never empty."],"exampleFix":"// before\nc, err := ring.Dial(ctx, \"front-door-cam\", token)\n// after\nc, err := ring.Dial(ctx, \"12345678\", token)","handlingStrategy":"validation","validationCode":"if cameraID == \"\" {\n    return errors.New(\"camera_id must not be empty\")\n}\nif _, err := strconv.Atoi(strings.TrimSpace(cameraID)); err != nil {\n    return fmt.Errorf(\"camera_id must be numeric, got %q\", cameraID)\n}","typeGuard":null,"tryCatchPattern":"client, err := ring.Dial(ctx, cameraID, token)\nif err != nil {\n    if strings.Contains(err.Error(), \"invalid camera_id\") {\n        // surface a config fix prompt to the user\n    }\n    return err\n}","preventionTips":["Store the numeric camera ID, never the device name or UUID.","Trim whitespace from values read from env vars or config files.","Validate all IDs at config-load time, before constructing clients."],"tags":["ring","camera","parsing","configuration"],"backgroundTag":"invalid-argument-format","analyzedSha":"c245815e75e2a5fd60b4290f12bfc04e55a984d3","analyzedAt":"2026-09-07T11:47:02.965Z","contentChangedAt":"2026-09-07T11:47:02.965Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}