canonical / rockcraft

Tool to create OCI Images using the language from Snapcraft and Charmcraft.
GNU General Public License v3.0
37 stars 44 forks source link

Confusing schema validation message for `platforms.<platform>.build-on`. #632

Closed aznashwan closed 4 months ago

aznashwan commented 4 months ago

Bug Description

When mis-inputting the platforms.<platform>.build-on rockcraft.yaml field as a single string instead of a list of strings, the resulting error message makes it sound like the <platform>: dict should be the one which is a list.

To Reproduce

Please rockcraft build the below-listed rockcraft.yml.

Environment

rockcraft.yaml

# Basically the example from the below tutorial with a modified `platforms` section:
# https://documentation.ubuntu.com/rockcraft/en/latest/tutorials/chisel/#project-setup

platforms:
  arm64:
    # NOTE: this should be a list of strings:
    build-on: amd64

### Unmodified rest of spec:
name: chiselled-hello
summary: Hello world from Chisel slices
description: A "bare" rock containing the "hello" package binaries from Chisel slices.
license: Apache-2.0

version: "latest"
base: bare
build_base: "ubuntu@22.04"

parts:
  hello:
    plugin: nil
    stage-packages:
      - hello_bins

Relevant log output

$ rockcraft build --debug
Bad rockcraft.yaml content:
- error for platform entry 'arm64': value is not a valid list (in field 'platforms')                                                                 
For more information, check out: https://documentation.ubuntu.com/rockcraft/en/stable/reference/rockcraft.yaml
tigarmo commented 4 months ago

Coincidentally, a recent merge affected this message. Now, this platform declaration:

platforms:
  my-platform:
    build-on: amd64

gives this error message, which includes the platform name:

❯ rockcraft pack
Bad rockcraft.yaml content:
- value is not a valid list (in field 'platforms.my-platform.build-on')

in my opinion this is enough of an improvement, what do you think?

aznashwan commented 4 months ago

Coincidentally, a https://github.com/canonical/rockcraft/pull/567 affected this message. Now, this platform declaration:

The new error message looks great, way clearer than the original error with no potential for confusion!

Thank you, and please feel free to mark this issue as 'resolved'.