Skip to content

cli: don't ignore errors from setting property aliases

Lubomir Rintel requested to merge lr/property-alias-err into main

Before, we would just ignore the errors when we passed an invalid value to a property alias:

  $ nmcli c add type ethernet mac Hello
  Connection 'ethernet-1' (242eec76-7147-411a-a50b-336cf5bc8137) successfully added.
  $ nmcli c show 242eec76-7147-411a-a50b-336cf5bc8137 |grep 802-3-ethernet.mac-address:
  802-3-ethernet.mac-address:             --

...or crash, because the GError would still be around:

  $ nmcli c add type ethernet mac Hello ethernet.mac-address World
  (process:734670): GLib-WARNING **: 14:52:51.436: GError set over the top of a previous GError or uninitialized memory.
  This indicates a bug in someone's code. You must ensure an error is NULL before it's set.
  The overwriting error message was: Error: failed to modify 802-3-ethernet.mac-address: 'World' is not a valid Ethernet MAC.
  Error: failed to modify 802-3-ethernet.mac-address: 'Hello' is not a valid Ethernet MAC.

Now we catch it early enough:

  $ nmcli c add type ethernet mac Hello
  Error: failed to modify 802-3-ethernet.mac-address: 'Hello' is not a valid Ethernet MAC.

Merge request reports