Received an error trying to parse my OpenWRT config (open native) because there was a route that does not have a gateway assigned (wan exit route to reach the modem).
>>> router = OpenWrt(native=open('./backup-sc-router-2023-11-30.tar.gz'))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/mnt/c/Users/timjb/src/router/venv/lib/python3.11/site-packages/netjsonconfig/backends/openwrt/openwrt.py", line 51, in __init__
super().__init__(config, native, templates, context)
File "/mnt/c/Users/timjb/src/router/venv/lib/python3.11/site-packages/netjsonconfig/backends/base/backend.py", line 51, in __init__
self.parse(native)
File "/mnt/c/Users/timjb/src/router/venv/lib/python3.11/site-packages/netjsonconfig/backends/base/backend.py", line 329, in parse
self.to_netjson()
File "/mnt/c/Users/timjb/src/router/venv/lib/python3.11/site-packages/netjsonconfig/backends/base/backend.py", line 342, in to_netjson
value = converter.to_netjson()
^^^^^^^^^^^^^^^^^^^^^^
File "/mnt/c/Users/timjb/src/router/venv/lib/python3.11/site-packages/netjsonconfig/backends/base/converter.py", line 116, in to_netjson
result = self.to_netjson_loop(block, result, index + 1)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/mnt/c/Users/timjb/src/router/venv/lib/python3.11/site-packages/netjsonconfig/backends/openwrt/converters/routes.py", line 39, in to_netjson_loop
rule = self.__netjson_route(block, index)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/mnt/c/Users/timjb/src/router/venv/lib/python3.11/site-packages/netjsonconfig/backends/openwrt/converters/routes.py", line 57, in __netjson_route
"next": route.pop('gateway'),
^^^^^^^^^^^^^^^^^^^^
KeyError: 'gateway'
Received an error trying to parse my OpenWRT config (open native) because there was a route that does not have a gateway assigned (wan exit route to reach the modem).
Valid config from OpenWRT: