wobcom / cosmo

a fairly odd fairy to generate network configuration from Netbox
MIT License
6 stars 0 forks source link

TypeError: 'NoneType' object is not subscriptable when generating LRMB0001 #29

Open loulecrivain opened 1 month ago

loulecrivain commented 1 month ago

Full trace here:

Traceback (most recent call last):
  File "/nix/store/9zzc7pvq63m5h9r69sk19qhvydxqxzz2-python3.11-cosmo-0.8.4/bin/.cosmo-wrapped", line 9, in <module>
    sys.exit(main())
             ^^^^^^
  File "/nix/store/9zzc7pvq63m5h9r69sk19qhvydxqxzz2-python3.11-cosmo-0.8.4/lib/python3.11/site-packages/cosmo/__main__.py", line 81, in main
    content = serializer.serialize()
              ^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/9zzc7pvq63m5h9r69sk19qhvydxqxzz2-python3.11-cosmo-0.8.4/lib/python3.11/site-packages/cosmo/serializer.py", line 455, in serialize
    name, unit = self._get_unit(si)
                 ^^^^^^^^^^^^^^^^^^
  File "/nix/store/9zzc7pvq63m5h9r69sk19qhvydxqxzz2-python3.11-cosmo-0.8.4/lib/python3.11/site-packages/cosmo/serializer.py", line 319, in _get_unit
    if i["address"] == connected["primary_ip4"]["address"]:
                       ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
TypeError: 'NoneType' object is not subscriptable

I believe this is happens because connected is None, we should add a check somewhere

loulecrivain commented 1 month ago

poke @vidister, since this is located in code from your latest merge request I believe