`snap remove` should reject commands with invalid snap names

Bug #1842203 reported by Merlijn Sebrechts
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
snapd
Fix Released
High
Miguel Pires

Bug Description

If you run `snap remove` with bad arguments, it currently assumes all arguments are snap names, regardless of whether these names are valid or not. As a result, slightly mistyping a `snap remove` command has very bad consequences.

Assume you refresh a snap to the latest version to see that it is broken. You revert to a previous revision and you want to remove the latest revision. This is what happens when you forget the two hyphens before `revision`.

```bash
merlijn@howard:~$ snap remove sdlpop revision=131
sdlpop removed
revision=131 not installed
```

Snap removes `sdlpop` entirely and tries to remove the snap `revision=131`. This causes irreversible damage since you can only revert to versions you have cached locally, so you lose the ability to use the previous working revision. This has already happened: https://forum.snapcraft.io/t/accidentally-removed-snap-package-how-to-revert-to-older-revision/12982?u=galgalesh

In order to prevent users from accidentally shooting themselves in the foot, `snap remove` should check if all arguments are valid snap names. If they are not, `snap remove` should error out.

Revision history for this message
John Lenton (chipaca) wrote :

The user data is not removed unless you also specified --purge (on reinstalling the app, 'snap restore sdlpop' would bring it back).

Revision history for this message
John Lenton (chipaca) wrote :

(sorry, 'snap restore' takes a snapshot id, use 'snap saved' to see the id)

description: updated
description: updated
Changed in snapd:
status: New → Confirmed
importance: Undecided → High
Changed in snapd:
assignee: nobody → Samuele Pedroni (pedronis)
Revision history for this message
Miguel Pires (miguelpires1) wrote :
Changed in snapd:
assignee: Samuele Pedroni (pedronis) → Miguel Pires (miguelpires1)
status: Confirmed → In Progress
Changed in snapd:
status: In Progress → Fix Committed
Changed in snapd:
status: Fix Committed → Fix Released
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.