The serial-port interface fails silently if path doesn't match undocumented regex

Hey all. I recently finished a soon-to-be-published blog series walking the reader through taking a ROS prototype to production with Ubuntu Core. Part of this series is creating a custom gadget snap to expose serial ports to the ROS snap, and creating a custom image with this gadget and ROS snap pre-installed.

This effort ultimately ended in success, but I wanted to provide some feedback about some of the rough edges I encountered while going through this process. This is one of those rough edges, and ate a particularly large chunk of time.

I initially attempted to define the serial-port slot like the following:

slots:
  kobuki:
    interface: serial-port
    path: /dev/kobuki
    usb-vendor: 0x0403
    usb-product: 0x6001

However, once I created the image and booted it, that slot didn’t show up in snap interfaces. At no time during this process was I informed that my slot was invalid simply because I didn’t use a path that matched /dev/serial-port-<something>. Snapd warns about invalid interfaces when installing app snaps, it’d be handy if it also warned when creating an image using a gadget snap with invalid interfaces. It would also be nice to get this documented. I logged a bug to discuss this.

The fact is fails silently is definitely a problem. The underlying issue here is that we lack a good warning mechanism to reach the user interface. We have good logging in the change and task framework, and good errors, but no way to surface a message that something isn’t quite right but we’re going ahead nevertheless.

We need to implement a bit of the backing infrastructure for that, and then it’ll be easy to do a better job in these cases.