fix(driver): leave unsupported getters to NAPALM's stubs #14

Merged
christianmanivong merged 1 commits from fix/get-config-stub into main 2026-11-12 18:14:10 +00:00
Owner

What was wrong

SonosDriver.get_config(self) overrode NAPALM's stub with return {} and took no arguments. A caller that asks whether the driver has its own get_config (comparing it against NAPALM's stub) sees one, calls get_config(retrieve="running"), and gets a TypeError. netOrk records that as a failed configuration backup on every poll of every Sonos speaker.

Cause

The driver overrode every NAPALM getter a speaker has nothing for with an empty answer. Besides get_config, the same shape applied to 19 more getters: get_environment, get_optics, get_arp_table, get_route_to, get_mac_address_table, get_lldp_neighbors(_detail), get_ntp_peers/servers/stats, get_snmp_information, get_users, get_network_instances, get_bgp_config, get_bgp_neighbors(_detail), get_probes_config/results, get_firewall_policies.

All of them would be mistaken for implemented getters:

  • get_route_to(self, destination) required an argument NAPALM defaults, so get_route_to() raised TypeError too (a warning in the poll log on every poll).
  • get_ntp_servers() answering {} reads as "NTP read, no servers configured", which is a statement about the speaker the driver cannot make.
  • get_arp_table() answering [] reads as "read, empty" rather than "not read".
  • The rest answered {}/[] for data the speaker does not have, which STANDARDS §3 rules out ("Returning an empty result for 'could not read' makes a broken device look like an empty one").

Fix

Same as NAPALM/napalm-zyxel#22: the overrides are removed, so NAPALM's stubs stay and raise NotImplementedError. A caller can tell "not supported" from "read, empty" again.

Kept as they are (not getters, out of scope): ping()/traceroute() (return NAPALM's error key), cli() (returns []), and the no-op commit_config(), discard_config(), compare_config(), rollback().

README ("Not supported") and CHANGELOG ([Unreleased], marked breaking: the methods now raise instead of answering empty) are updated.

Tests

Fixtures only (no device).

  • test_an_unsupported_getter_is_napalms_stub[...]: for each of the 20 getters, the driver's attribute is NAPALM's NetworkDriver stub. Failed before the change (20 red).
  • test_get_config_with_napalms_arguments_says_not_implemented: get_config(retrieve="running") raises NotImplementedError; failed with TypeError before.
  • test_get_route_to_with_napalms_defaults_says_not_implemented: get_route_to() raises NotImplementedError; failed with TypeError before.
  • test_get_arp_table_takes_napalms_vrf_argument (from #2) is replaced by the parametrised test: NAPALM's stub takes vrf.

pytest 76 passed (coverage 92 %), ruff format/check clean, mypy clean, napalm-standard check and ratchet green.

Closes #13

## What was wrong `SonosDriver.get_config(self)` overrode NAPALM's stub with `return {}` and took no arguments. A caller that asks whether the driver has its own `get_config` (comparing it against NAPALM's stub) sees one, calls `get_config(retrieve="running")`, and gets a `TypeError`. netOrk records that as a failed configuration backup on every poll of every Sonos speaker. ## Cause The driver overrode every NAPALM getter a speaker has nothing for with an empty answer. Besides `get_config`, the same shape applied to 19 more getters: `get_environment`, `get_optics`, `get_arp_table`, `get_route_to`, `get_mac_address_table`, `get_lldp_neighbors(_detail)`, `get_ntp_peers/servers/stats`, `get_snmp_information`, `get_users`, `get_network_instances`, `get_bgp_config`, `get_bgp_neighbors(_detail)`, `get_probes_config/results`, `get_firewall_policies`. All of them would be mistaken for implemented getters: - `get_route_to(self, destination)` required an argument NAPALM defaults, so `get_route_to()` raised `TypeError` too (a warning in the poll log on every poll). - `get_ntp_servers()` answering `{}` reads as "NTP read, no servers configured", which is a statement about the speaker the driver cannot make. - `get_arp_table()` answering `[]` reads as "read, empty" rather than "not read". - The rest answered `{}`/`[]` for data the speaker does not have, which STANDARDS §3 rules out ("Returning an empty result for 'could not read' makes a broken device look like an empty one"). ## Fix Same as NAPALM/napalm-zyxel#22: the overrides are removed, so NAPALM's stubs stay and raise `NotImplementedError`. A caller can tell "not supported" from "read, empty" again. Kept as they are (not getters, out of scope): `ping()`/`traceroute()` (return NAPALM's `error` key), `cli()` (returns `[]`), and the no-op `commit_config()`, `discard_config()`, `compare_config()`, `rollback()`. README ("Not supported") and CHANGELOG (`[Unreleased]`, marked breaking: the methods now raise instead of answering empty) are updated. ## Tests Fixtures only (no device). - `test_an_unsupported_getter_is_napalms_stub[...]`: for each of the 20 getters, the driver's attribute is NAPALM's `NetworkDriver` stub. Failed before the change (20 red). - `test_get_config_with_napalms_arguments_says_not_implemented`: `get_config(retrieve="running")` raises `NotImplementedError`; failed with `TypeError` before. - `test_get_route_to_with_napalms_defaults_says_not_implemented`: `get_route_to()` raises `NotImplementedError`; failed with `TypeError` before. - `test_get_arp_table_takes_napalms_vrf_argument` (from #2) is replaced by the parametrised test: NAPALM's stub takes `vrf`. pytest 76 passed (coverage 92 %), ruff format/check clean, mypy clean, `napalm-standard check` and `ratchet` green. Closes #13
christianmanivong added 1 commit 2026-11-12 17:54:25 +00:00
fix(driver): leave unsupported getters to NAPALM's stubs
driver / lint (pull_request) Successful in 15s
driver / standard (pull_request) Successful in 17s
driver / types (pull_request) Successful in 1m0s
driver / test (3.13) (pull_request) Successful in 4m13s
driver / test (3.12) (pull_request) Successful in 4m15s
driver / lowest (pull_request) Successful in 3m42s
driver / build (pull_request) Successful in 27s
driver / security (pull_request) Successful in 1m8s
CI / driver (pull_request) Successful in 5m38s
driver / publish (pull_request) Skipped
56e0560eb2
get_config() overrode NAPALM's stub with `return {}` and took no
arguments, so get_config(retrieve="running") raised TypeError, which a
caller reports as a failed configuration backup on every poll. The
other getters a speaker has nothing for (environment, optics, routing,
ARP, MAC table, LLDP, NTP, SNMP, BGP, probes, users, network instances,
firewall policies) had the same shape: an empty answer reads as
"implemented, nothing there", and get_route_to() required an argument
NAPALM defaults.

All of them are gone; NAPALM's stubs raise NotImplementedError.

Closes #13
christianmanivong merged commit bb55884216 into main 2026-11-12 18:14:10 +00:00
christianmanivong deleted branch fix/get-config-stub 2026-11-12 18:14:10 +00:00
Sign in to join this conversation.