Comment 0 for bug 1842203

Revision history for this message
Merlijn Sebrechts (merlijn-sebrechts) wrote :

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 just refreshed a snap to the latest version and you want to remove a previous version of this snap. 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 all user data and previous versions of sdlpop are removed. 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.