It is possible to make a snap with an empty version

Bug #1660076 reported by Leo Arias
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Canonical Click Reviewers tools (obsolete)
Invalid
Undecided
Unassigned
Snapcraft
Fix Released
Undecided
RoxD
snapd
Invalid
Undecided
Unassigned

Bug Description

The version of the snaps is free form, but we should at least verify that it is a non-empty string.

Currently it is possible to write a snap with

"version: "

or

"version: ''"

and snapcraft won't complain.

In this cases, an error message should be returned.

To reproduce:

$ snapcraft init
$ sed -i "s/version:.*$/version: ''/g" snapcraft.yaml
$ snapcraft
[...]
Snapped my-snap-name__amd64.snap <- Note the missing version.

$ sed -i "s/version:.*$/version: /g" snapcraft.yaml
$ snapcraft
[...]
Snapped my-snap-name_None_amd64.snap <- Note "None" instead of the version.

Tags: bitesize ui
Leo Arias (elopio)
tags: added: ui
Revision history for this message
Leo Arias (elopio) wrote :

Note that this will build successfully, but it will fail when pushed to the store.

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

Does it install, though?

Revision history for this message
Leo Arias (elopio) wrote :

Yes, it can be installed.

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

Perhaps this should apply to snapd as well, then?

Revision history for this message
Leo Arias (elopio) wrote :

I'm not sure, but I've marked it as affecting them to discuss it.

As they don't use the version for anything, maybe it's valid to have a local snap with an empty version. I don't see why, but maybe.

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

In my mind, if it's valid, then all tools (snapcraft and the review tools) should accept it. If it's invalid, none of them should. Thoughts?

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

Adding the review tools as well to broaden the discussion to all affected parties.

Changed in snapcraft:
importance: Medium → Undecided
RoxD (roxd)
Changed in snapcraft:
assignee: nobody → RoxD (roxd)
status: New → In Progress
Revision history for this message
Sergio Schvezov (sergiusens) wrote :

sergiusens@mirkwood:~/t$ snapcraft
Issues while validating snapcraft.yaml: The 'version' property does not match the required schema: '' does not match '^[a-zA-Z0-9.+~-]+$'
sergiusens@mirkwood:~/t$ grep version snap/snapcraft.yaml
version: '' # just for humans, typically '1.2+git' or '1.3.2'
sergiusens@mirkwood:~/t$ snapcraft --version
snapcraft, version 2.33

Changed in snapcraft:
status: In Progress → Fix Committed
status: Fix Committed → Fix Released
Revision history for this message
Zygmunt Krynicki (zyga) wrote :

I'm closing the snapd part of this bug as it is possible to hand-craft a snap with an empty version AFAIK

Changed in snapd:
status: New → Invalid
Revision history for this message
Jamie Strandboge (jdstrand) wrote :

Closing the review tools task since it has always required the version field be non-empty:

Errors
------
 - lint-snap-v2:version_valid
 malformed 'version': ''

Changed in click-reviewers-tools:
status: New → Invalid
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.