get_playback_state / get_zone_info do not follow the media contract's shapes; get_group_info and get_zone_info swallow failures #11

Closed
opened 2026-11-02 08:24:11 +00:00 by christianmanivong · 0 comments
Owner

What happens

  1. Contract shapes. napalm-device-types' media contract (napalm_device_types/media.py) declares get_playback_state() -> dict (state: "playing"/"paused"/"stopped"/"transitioning", plus source) and get_zone_info() -> list[dict]. The Sonos driver returns a bare string ("PLAYING", "PAUSED_PLAYBACK", "STOPPED", napalm_sonos/sonos_driver.py:317) and a single dict (get_zone_info, line 409).
  2. Swallowed failures. get_group_info (line 385) and get_zone_info end in
    except Exception:
        return {}
    
    so a failed read is reported as "no group" / "no zone". (#9 fixes the same for volume, mute, playback state and track.)

Expected

Both getters follow the device-types contract shape and raise on a failed read (ConnectionException for an unreachable speaker, CommandErrorException for a UPnP error), as #9 does for the others. Test-first with MagicMock(spec=soco.SoCo).

Priority: P4 — netOrk does not call these getters today; any other consumer of the contract gets the wrong shape.

Found during the bug sweep of 2026-11-02 (#9).

## What happens 1. **Contract shapes.** napalm-device-types' media contract (`napalm_device_types/media.py`) declares `get_playback_state() -> dict` (`state`: `"playing"`/`"paused"`/`"stopped"`/`"transitioning"`, plus `source`) and `get_zone_info() -> list[dict]`. The Sonos driver returns a bare string (`"PLAYING"`, `"PAUSED_PLAYBACK"`, `"STOPPED"`, `napalm_sonos/sonos_driver.py:317`) and a single dict (`get_zone_info`, line 409). 2. **Swallowed failures.** `get_group_info` (line 385) and `get_zone_info` end in ```python except Exception: return {} ``` so a failed read is reported as "no group" / "no zone". (#9 fixes the same for volume, mute, playback state and track.) ## Expected Both getters follow the device-types contract shape and raise on a failed read (`ConnectionException` for an unreachable speaker, `CommandErrorException` for a UPnP error), as #9 does for the others. Test-first with `MagicMock(spec=soco.SoCo)`. Priority: P4 — netOrk does not call these getters today; any other consumer of the contract gets the wrong shape. Found during the bug sweep of 2026-11-02 (#9).
christianmanivong added the
prio
P4
bug
labels 2026-11-02 08:24:11 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: NAPALM/napalm-sonos#11