From 9af9be92a143fadd853cfdbdfffb5f68ad4dcf0e Mon Sep 17 00:00:00 2001 From: malmert Date: Sat, 28 Feb 2026 23:03:54 +0100 Subject: [PATCH] test --- backend/src/api/nft_manager.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/backend/src/api/nft_manager.py b/backend/src/api/nft_manager.py index 93c9e7e..6ff129f 100644 --- a/backend/src/api/nft_manager.py +++ b/backend/src/api/nft_manager.py @@ -62,6 +62,18 @@ class NftManager: return json.loads(out) except json.JSONDecodeError as e: raise NftError(f"json decode error: {e}") + + def list_rules_text(self) -> str: + """ + Obtain nft list ruleset in textual form. This is a fallback if JSON parsing fails. + Returns raw textual output on success, raises NftError on failure. + """ + self.nft.set_json_output(False) # best-effort attempt to disable JSON output + res = self.cmd("list ruleset") + self.nft.set_json_output(True) # restore JSON output preference + if res["rc"] != 0: + raise NftError(f"nft list ruleset failed: {res['stderr']}") + return res["stdout"] or "" def list_chain_text(self, family: str, table: str, chain: str) -> str: """ @@ -696,6 +708,8 @@ def list_rules(): try: try: nft_json = mgr.list_rules_json() + nft_text = mgr.list_rules_text() + logger.error("Successfully obtained nft JSON ruleset, but also got textual output: %r", nft_text) except NftError as e: logger.debug("could not obtain nft JSON ruleset: %s", e) text = mgr.list_rules_json()