AlexxIT/go2rtc · error
ring: invalid camera_id
Error message
ring: invalid camera_id: %w
What it means
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.
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.
Example fix
// before c, err := ring.Dial(ctx, "front-door-cam", token) // after c, err := ring.Dial(ctx, "12345678", token)
Defensive patterns
Strategy: validation
Validate before calling
if cameraID == "" {
return errors.New("camera_id must not be empty")
}
if _, err := strconv.Atoi(strings.TrimSpace(cameraID)); err != nil {
return fmt.Errorf("camera_id must be numeric, got %q", cameraID)
} Try / catch
client, err := ring.Dial(ctx, cameraID, token)
if err != nil {
if strings.Contains(err.Error(), "invalid camera_id") {
// surface a config fix prompt to the user
}
return err
} Prevention
- 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.
When it happens
Trigger: 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).
Common situations: 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.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- wrong response:
- wrong auth response
- wrong start byte
- credentials: storage not initialized
- eseecloud: wrong start byte
AI-assisted analysis of AlexxIT/go2rtc@c245815e75 (2026-09-07).
Data as JSON: /api/errors/431006f78cecb482.
Report an issue: GitHub.
Appendix: source
Thrown at pkg/ring/client.go:48
}
query := u.Query()
encodedToken := query.Get("refresh_token")
cameraID := query.Get("camera_id")
deviceID := query.Get("device_id")
_, isSnapshot := query["snapshot"]
if encodedToken == "" || deviceID == "" || cameraID == "" {
return nil, errors.New("ring: wrong query")
}
client := &Client{
dialogID: uuid.NewString(),
}
client.cameraID, err = strconv.Atoi(cameraID)
if err != nil {
return nil, fmt.Errorf("ring: invalid camera_id: %w", err)
}
refreshToken, err := url.QueryUnescape(encodedToken)
if err != nil {
return nil, fmt.Errorf("ring: invalid refresh token encoding: %w", err)
}
client.api, err = NewRestClient(RefreshTokenAuth{RefreshToken: refreshToken}, nil)
if err != nil {
return nil, err
}
// Snapshot Flow
if isSnapshot {
client.prod = NewSnapshotProducer(client.api, client.cameraID)
return client, nil
}
View on GitHub (pinned to c245815e75)