Content interface parsing too lenient

Bug #1666739 reported by Michi Henning
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Snapcraft
New
Undecided
Unassigned

Bug Description

The following is accepted by snapcraft without error:

 client-libs:
    interface: content
    content: client-libs
    read: $SNAP/lib/client

When installing the snap, I get the message:

    ... bad plugs or slots client-libs (read or write path must be set)

The above should be instead:

 client-libs:
    interface: content
    content: client-libs
    read: [$SNAP/lib/client]

Or:

 client-libs:
    interface: content
    content: client-libs
    read:
      - $SNAP/lib/client

snapcraft should tell me that my yaml is invalid instead of silently failing to set the attribute.

Revision history for this message
Kyle Fazzari (kyrofa) wrote :

This is a section of the YAML that snapcraft silently passes through to snapd (it doesn't process it whatsoever). Actually validating it would require one of two things:

1) snapcraft to maintain a schema for all snapd interfaces
2) snapd to add some sort of validation function

(1) is problematic as, first of all, it's redundant. That information is already maintained in snapd. It would also require either the snapcraft team to closely monitor snapd PRs, or require the snapd team to notify the snapcraft team whenever they're making an interface change. They're also released on separate schedules, so you might end up with snapcraft not passing a schema that's actually valid in a newer snapd, or vice-versa.

(2) is possible, but would need to be implemented by snapd, and Snapcraft would need to actually depend upon snapd (it's currently only a Suggests), which would throw it into dist-upgrade territory.

I'm not sure there's an elegant solution for this.

Revision history for this message
Michi Henning (michihenning) wrote :

I hear you on the difficulty of fixing this, but I think it needs to be fixed regardless. It sucks if I make an innocent mistake and nothing alerts me to the fact that I've just written nonsense. (How would I feel if the C compiler simply would say nothing for an incorrect statement and silently not generate code for it?)

The YAML is a little language and, like all languages, needs to have complete and thorough syntax and semantic checks. Not doing this really is a disservice to developers.

Revision history for this message
Kyle Fazzari (kyrofa) wrote :

I agree, I'm just not sure what the best solution might be. I'll bring this up at standup to discuss.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.