Skip to content

Streams list decode fails when any stream has a WHIP/WebRTC push producer (Producer.url missing) #344

Description

@eric-benjamin

Summary

Go2RtcRestClient.streams.list() raises Go2RtcClientError whenever any stream in go2rtc has a producer that was pushed into it (WHIP ingest / WebRTC push). Pushed producers have no "url" key in the /api/streams payload — there is no source URL, the media was pushed — but Producer.url is declared required, so one pushed stream anywhere makes the entire streams list undecodable.

Impact (how this surfaces in Home Assistant)

With go2rtc: url: pointing HA at a go2rtc instance that also receives WHIP publishes (e.g. kiosk tablets publishing their cameras via browser_mod's go2rtc mode), every code path in the go2rtc integration that calls streams.list() fails while a publisher is connected:

  • async_get_imageevery camera still image in the instance returns 500 (all cameras, not just the pushed stream)
  • ws_webrtc_offer → WebRTC playback offers fail

The failure is intermittent-looking (it tracks whether a publisher is currently connected), which made it painful to diagnose.

Actual payload from go2rtc v1.9.14

Producer entry for a WHIP-published stream — note there is no url key:

{
  "id": 4439,
  "format_name": "webrtc",
  "protocol": "http+udp",
  "remote_addr": "192.168.10.212:59793 host",
  "user_agent": "Mozilla/5.0 (Linux; Android 8.1.0; ...; wv) ... Chrome/138.0.7204.181 Safari/537.36",
  "medias": ["video, recvonly, H264", "video, sendonly, VP8, VP9, H264"],
  "receivers": [{"id": 4440, "codec": {"codec_name": "h264", "codec_type": "video"}, "childs": [4447, 4456], "bytes": 37630084, "packets": 34687}],
  "bytes_recv": 38330115
}

Traceback (HA 2026.7.2, go2rtc-client 0.4.0)

mashumaro.exceptions.MissingField: Field "url" of type str is missing in Producer instance

During handling of the above exception, another exception occurred:
...
  File ".../go2rtc_client/rest.py", line 141, in list
    return _GET_STREAMS_DECODER.decode(await resp.json())
mashumaro.exceptions.InvalidFieldValue: Field "producers" of type list[Producer] in Stream has invalid value [...]

The above exception was the direct cause of the following exception:
...
  File ".../homeassistant/components/go2rtc/__init__.py", line 408, in _update_stream_source
    streams = await self._rest_client.streams.list()
go2rtc_client.exceptions.Go2RtcClientError

Reproduction

  1. Run go2rtc with a declared stream, e.g. streams: { "kiosk": }.
  2. Publish into it via WHIP (POST /api/webrtc?dst=kiosk from any browser, OBS, etc.).
  3. await client.streams.list()Go2RtcClientError.

Fix

Make Producer.url optional (str | None = None), matching what go2rtc actually reports. Same category as #21, which handled producers itself being null. PR incoming.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions