A failed request to the gateway raises instead of reading as empty data.
_dal_query and _fetch_page raise ConnectionException when the gateway does not answer or refuses the session (HTTP 401/403), and RuntimeError naming the request (DAL <oid> / GET <path>) for any other HTTP error or an answer that cannot be read. They returned None for every failure, including except Exception in _dal_query.
The getters that read the DAL with an HTML page as fallback (get_hosts, get_port_forwards, get_wireless_clients, get_ssids, get_radio_status) go through one helper, _read_dal_or_page: the DAL answer when it can be read, else the page; when the page fails too, the getter raises. get_arp_table and get_nat_translations build on them and raise with them. get_radio_status's inline parsing moves into _parse_radio_status_dal / _parse_radio_status_html (complexity 14 → under the limit; its baseline entry is gone).
get_diagnostics, reboot_host and restart_wifi raise when their DAL request fails. The refused-answer checks of the two actions are unchanged.
get_facts no longer turns a failed get_interfaces into interface_list=[].
Why
A timeout or an expired session read as a gateway with no hosts, port forwards, SSIDs or Wi-Fi clients.
Tests
Fixtures only (no device). tests/test_failed_reads.py drives the driver against a stub session answering per path: _dal_query with timeout, 401/403, 500 and a non-JSON answer; every DAL-or-page getter with both sources failing; the page fallback; a DAL answer with no hosts reading as none; get_facts with get_interfaces raising. 14 of them failed before the change. The stub's driver does not let NAPALM's __del__ open a TCP connection through is_alive().
pytest 66 passed, ruff format/check clean, mypy clean, napalm-standard check passes, napalm-standard ratchet within the baseline (one complexity entry fewer).
## What
A failed request to the gateway raises instead of reading as empty data.
- `_dal_query` and `_fetch_page` raise `ConnectionException` when the gateway does not answer or refuses the session (HTTP 401/403), and `RuntimeError` naming the request (`DAL <oid>` / `GET <path>`) for any other HTTP error or an answer that cannot be read. They returned `None` for every failure, including `except Exception` in `_dal_query`.
- The getters that read the DAL with an HTML page as fallback (`get_hosts`, `get_port_forwards`, `get_wireless_clients`, `get_ssids`, `get_radio_status`) go through one helper, `_read_dal_or_page`: the DAL answer when it can be read, else the page; when the page fails too, the getter raises. `get_arp_table` and `get_nat_translations` build on them and raise with them. `get_radio_status`'s inline parsing moves into `_parse_radio_status_dal` / `_parse_radio_status_html` (complexity 14 → under the limit; its baseline entry is gone).
- `get_diagnostics`, `reboot_host` and `restart_wifi` raise when their DAL request fails. The refused-answer checks of the two actions are unchanged.
- `get_facts` no longer turns a failed `get_interfaces` into `interface_list=[]`.
## Why
A timeout or an expired session read as a gateway with no hosts, port forwards, SSIDs or Wi-Fi clients.
## Tests
Fixtures only (no device). `tests/test_failed_reads.py` drives the driver against a stub session answering per path: `_dal_query` with timeout, 401/403, 500 and a non-JSON answer; every DAL-or-page getter with both sources failing; the page fallback; a DAL answer with no hosts reading as none; `get_facts` with `get_interfaces` raising. 14 of them failed before the change. The stub's driver does not let NAPALM's `__del__` open a TCP connection through `is_alive()`.
pytest 66 passed, ruff format/check clean, mypy clean, `napalm-standard check` passes, `napalm-standard ratchet` within the baseline (one complexity entry fewer).
Closes #15
_dal_query and _fetch_page returned None for any failure, and the
getters turned that into empty data, so a timeout or an expired session
read as a gateway with no hosts, port forwards, SSIDs or Wi-Fi clients.
Both now raise: ConnectionException when the gateway does not answer or
refuses the session, RuntimeError naming the request otherwise. A getter
whose DAL request fails still reads the HTML page and raises when that
fails too; get_facts no longer swallows a failed get_interfaces.
Closes#15
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
What
A failed request to the gateway raises instead of reading as empty data.
_dal_queryand_fetch_pageraiseConnectionExceptionwhen the gateway does not answer or refuses the session (HTTP 401/403), andRuntimeErrornaming the request (DAL <oid>/GET <path>) for any other HTTP error or an answer that cannot be read. They returnedNonefor every failure, includingexcept Exceptionin_dal_query.get_hosts,get_port_forwards,get_wireless_clients,get_ssids,get_radio_status) go through one helper,_read_dal_or_page: the DAL answer when it can be read, else the page; when the page fails too, the getter raises.get_arp_tableandget_nat_translationsbuild on them and raise with them.get_radio_status's inline parsing moves into_parse_radio_status_dal/_parse_radio_status_html(complexity 14 → under the limit; its baseline entry is gone).get_diagnostics,reboot_hostandrestart_wifiraise when their DAL request fails. The refused-answer checks of the two actions are unchanged.get_factsno longer turns a failedget_interfacesintointerface_list=[].Why
A timeout or an expired session read as a gateway with no hosts, port forwards, SSIDs or Wi-Fi clients.
Tests
Fixtures only (no device).
tests/test_failed_reads.pydrives the driver against a stub session answering per path:_dal_querywith timeout, 401/403, 500 and a non-JSON answer; every DAL-or-page getter with both sources failing; the page fallback; a DAL answer with no hosts reading as none;get_factswithget_interfacesraising. 14 of them failed before the change. The stub's driver does not let NAPALM's__del__open a TCP connection throughis_alive().pytest 66 passed, ruff format/check clean, mypy clean,
napalm-standard checkpasses,napalm-standard ratchetwithin the baseline (one complexity entry fewer).Closes #15