From 46aadbbe3b9c08be5326193ff84be69d8d248c43 Mon Sep 17 00:00:00 2001 From: Christian Manivong Date: Mon, 29 Jun 2026 12:11:35 +0200 Subject: [PATCH] fix(get_config): use plain text GET for running/startup config AOS-Switch returns the config body as text/plain, not JSON. The previous get_config() called self.get() which calls resp.json(), silently caught the JSONDecodeError, and returned ''. Now uses _get_text() which reads resp.text directly. --- napalm_procurve/api_client.py | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/napalm_procurve/api_client.py b/napalm_procurve/api_client.py index be7a921..18c1ff4 100644 --- a/napalm_procurve/api_client.py +++ b/napalm_procurve/api_client.py @@ -435,15 +435,28 @@ class ProcurveApiClient: return result def get_config(self) -> Dict[str, str]: - """Return running and startup configuration via REST API.""" - running = self.get("running-config") - startup = self.get("startup-config") + """Return running and startup configuration via REST API. + + AOS-Switch returns the config as plain text, not JSON. + """ return { - "running": running.get("config", ""), - "startup": startup.get("config", ""), + "running": self._get_text("running-config"), + "startup": self._get_text("startup-config"), "candidate": "", } + def _get_text(self, endpoint: str) -> str: + """GET *endpoint* and return the response body as plain text.""" + url = self._base_url + endpoint + try: + resp = self._session.get(url, timeout=self.timeout) + if resp.ok: + return resp.text + logger.warning("GET %s returned HTTP %s: %s", url, resp.status_code, resp.text[:200]) + except Exception as exc: + logger.warning("GET %s error: %s", url, exc) + return "" + def get_ntp_servers(self) -> Dict[str, Dict]: """Return NTP servers from REST API.""" data = self.get("ntp/server")