Gadget schema for ubuntu image parser might be broken

I am using ubuntu-image to make a ubuntu-core image. In the gadget.yaml definition, I added the update and edition definitions (link to documentation found in The gadget snap Snapcraft documentation.

The ubuntu_image/ does not include the this in the schema. As a result calling ubuntu_image will fail because of that added key that is not in the schema. Is it expected to not have an update when making an image for the first time?

If when building the image and this added definition should not be there, the documentation in the referred link should be updated to clearly state to not include that definition when building

If it is… I would constitute this as a bug, and the Schema should be updated.

Here is the Schema in

GadgetYAML = Schema({
    Optional('defaults'): {
        str: {
            str: object
    Optional('connections'): [Schema({
        Required('plug'): str,
        Optional('slot'): str,
    Optional('device-tree-origin', default='gadget'): str,
    Optional('device-tree'): str,
    Optional('format'): YAMLFormat,
    Required('volumes'): {
        Match('^[a-zA-Z0-9][-a-zA-Z0-9]*$'): Schema({
            Optional('schema', default='gpt' if has_new_voluptuous()
                    else VolumeSchema.gpt):
            Optional('bootloader'): Enumify(
                BootLoader, preprocessor=methodcaller('replace', '-', '')),
            Optional('id'): Coerce(Id),
            Required('structure'): [Schema({
                Optional('name'): str,
                Optional('offset'): Coerce(as_size),
                Optional('offset-write'): Any(
                    Coerce(Size32bit), RelativeOffset),
                Required('size'): Coerce(as_size),
                Required('type'): Any('mbr', 'bare', Coerce(HybridId)),
                Optional('role'): Enumify(
                    preprocessor=methodcaller('replace', '-', '_')),
                Optional('id'): Coerce(UUID),
                Optional('filesystem', default='none' if has_new_voluptuous()
                        else FileSystemType.none):
                Optional('filesystem-label'): str,
                Optional('content'): Any(
                        Required('source'): str,
                        Required('target'): str,
                    ],                                  # noqa: E124
                        Required('image'): str,
                        Optional('offset'): Coerce(as_size),
                        Optional('offset-write'): Any(
                            Coerce(Size32bit), RelativeOffset),
                        Optional('size'): Coerce(as_size),

Here is the YAML definition with the addition based off pc-amd64-gadget:gadget.yaml on the 18 branch

    bootloader: grub
      - name: mbr
        type: mbr
        size: 440
          - image: pc-boot.img
      - name: BIOS Boot
        type: DA,21686148-6449-6E6F-744E-656564454649
        size: 1M
        offset: 1M
        offset-write: mbr+92
          - image: pc-core.img
      - name: EFI System
        type: EF,C12A7328-F81F-11D2-BA4B-00A0C93EC93B
        filesystem: vfat
        filesystem-label: system-boot
        size: 50M
          - source: grubx64.efi
            target: EFI/boot/grubx64.efi
          - source: shim.efi.signed
            target: EFI/boot/bootx64.efi
          - source: mmx64.efi
            target: EFI/boot/mmx64.efi
          - source: grub.cfg
            target: EFI/ubuntu/grub.cfg
          - edition: 0

looks like ubuntu-image is a bit behind, better file a bug at:

I’ll look into fixing this in ubuntu-image

Opened a PR with and update to the schema validator.