AlexxIT/go2rtc · error

failed to unmarshal devices response

Error message

failed to unmarshal devices response: %w

What it means

The ring_devices response was received but json.Unmarshal into RingDevicesResponse failed, so the payload is malformed or has an unexpected schema. Wraps the unmarshal error; no device data is returned.

Solutions

  1. Retry in case of a truncated response
  2. Update RingDevicesResponse fields to match the current Ring API schema
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at pkg/ring/api.go:345 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at pkg/ring/api.go:345

	}

	// Refresh the cached client
	cacheMutex.Lock()
	clientCache[c.cacheKey] = c
	cacheMutex.Unlock()

	return c.authToken, nil
}

func (c *RingApi) FetchRingDevices() (*RingDevicesResponse, error) {
	response, err := c.Request("GET", ClientAPI("ring_devices"), nil)
	if err != nil {
		return nil, fmt.Errorf("failed to fetch ring devices: %w", err)
	}

	var devices RingDevicesResponse
	if err := json.Unmarshal(response, &devices); err != nil {
		return nil, fmt.Errorf("failed to unmarshal devices response: %w", err)
	}

	// Process "other" devices
	var onvifCameras []CameraData
	var intercoms []CameraData

	for _, device := range devices.Other {
		kind, ok := device["kind"].(string)
		if !ok {
			continue
		}

		switch RingDeviceType(kind) {
		case OnvifCameraType:
			var camera CameraData
			if deviceJson, err := json.Marshal(device); err == nil {
				if err := json.Unmarshal(deviceJson, &camera); err == nil {
					onvifCameras = append(onvifCameras, camera)

View on GitHub (pinned to c245815e75)