Bare except: clauses catch all exceptions including KeyboardInterrupt and SystemExit, which can mask critical errors and prevent proper program termination. Replace each with the narrowest exception type that the surrounding code actually needs to handle.
Files and exception types
| File | Line | Replacement | Rationale |
|---|---|---|---|
| src/conf_mode/interfaces_ethernet.py | 162 | Exception | Interface MTU lookup may fail for various OS-level reasons |
| src/conf_mode/vpp_interfaces_bonding.py | 181 | ValueError | assert_mac() raises ValueError on invalid MAC |
| src/conf_mode/container.py | 180 | IndexError | List comprehension [0] on empty filtered list |
| src/conf_mode/container.py | 186 | IndexError | List comprehension [0] on empty filtered list |
| python/vyos/config.py | 124 | Exception | ACME cert loading can fail from file I/O, parsing, etc. |
| python/vyos/configverify.py | 49 | Exception | Interface min/max MTU sysfs reads may fail |
| python/vyos/configverify.py | 436 | (TypeError, ValueError) | str() conversion of DH keysize parameter |