fix: get_config reads the backup as text, not JSON #12

Merged
christianmanivong merged 1 commits from fix/get-config-xml into master 2026-10-11 16:35:58 +00:00
Owner

/api/core/backup/download/this answers with config.xml, but get_config parsed it with .json(). That raised on every real device, the error was swallowed, and running came back empty. netOrk therefore never got an OPNsense configuration backup (NetOrk/netork#1016).

  • _get_text() returns the body as text, and get_config uses it.
  • A failed read now raises instead of returning "", so the caller sees the real reason (e.g. a 403).
  • New tests go through the real session path with an XML body. The old ones stubbed _get and so missed the bug.

Verified read-only against gw (172.22.8.50): 200, application/octet-stream, 505 KB XML, .json() → JSONDecodeError.

Closes #11

`/api/core/backup/download/this` answers with `config.xml`, but `get_config` parsed it with `.json()`. That raised on every real device, the error was swallowed, and `running` came back empty. netOrk therefore never got an OPNsense configuration backup (NetOrk/netork#1016). - `_get_text()` returns the body as text, and `get_config` uses it. - A failed read now raises instead of returning `""`, so the caller sees the real reason (e.g. a 403). - New tests go through the real session path with an XML body. The old ones stubbed `_get` and so missed the bug. Verified read-only against `gw` (172.22.8.50): 200, `application/octet-stream`, 505 KB XML, `.json()` → `JSONDecodeError`. Closes #11
christianmanivong added 1 commit 2026-10-11 16:35:52 +00:00
fix: get_config reads the backup as text, not JSON
CI / test (3.10) (push) Successful in 36s
CI / test (3.11) (push) Successful in 34s
CI / test (3.12) (push) Successful in 39s
CI / test (3.10) (pull_request) Successful in 32s
CI / test (3.11) (pull_request) Successful in 31s
CI / test (3.12) (pull_request) Successful in 33s
852c1d59df
/api/core/backup/download/this answers with config.xml itself, but
get_config went through _get(), which calls .json(). That raised on
every real device, the except swallowed it, and "running" came back
empty. The unit tests replaced _get with a lambda, so they never saw it.

_get_text() returns the body as text. A failed read now raises instead
of returning an empty string, so the caller sees why it failed.

Closes #11
christianmanivong merged commit e318c97c20 into master 2026-10-11 16:35:58 +00:00
christianmanivong deleted branch fix/get-config-xml 2026-10-11 16:35:58 +00:00
Sign in to join this conversation.