Can't rename image alias

ubuntu 18.04.03
snap lxd 3.16

I want to rename an image alias:

image list alias:
lxc image alias list

±---------------------------------------------±-------------±------------------+
| ALIAS | FINGERPRINT | DESCRIPTION |
±---------------------------------------------±-------------±------------------+
| Ubuntu 18.04 Bionic (amd64) with Salt minion | 0199b0cdd08b | |
±---------------------------------------------±-------------±------------------+

to rename alias:
lxc image alias rename ‘Ubuntu 18.04 Bionic (amd64) with Salt minion’ ‘salt-ubuntu-bionic’

Error: not found

tried with fingerprint and local: , but nothing works

I verify that indeed, an alias name like that (with spaces and parenthesis), cannot be renamed.
It is either an issue with the client or the server.

Run the following to show the database entry for the alias.
Then, we can create a command that will rename the alias by editing the database.

lxd sql global "SELECT * from images_aliases;"

The client sends verbatim the new alias name Ubuntu 18.04 Bionic (amd64) with Salt minion to the server when you create the alias. However, when you want to rename the alias, the alias name is part of the API endpoint. And it has spaces and parenthesis.

I haven’t checked, but this sounds very similar to https://github.com/lxc/lxd/pull/6081

Its on my list to look at and I will apply the change to all routes.

lxd sql global “SELECT * from images_aliases;”
±—±---------------------------------------------±---------±------------------±-----------+
| id | name | image_id | description | project_id |
±—±---------------------------------------------±---------±------------------±-----------+
| 16 | Ubuntu 18.04 Bionic (amd64) with Salt minion | 92 | | 1 |
±—±---------------------------------------------±---------±------------------±-----------+

This should be fixed in LXD 3.17 as the change has been merged now.

You can wait until Monday when LXD 3.17 will be released with a fix, or try the following now.
Make sure the parameters are correct for your setup.

Here is my setup, which shows the alias I created (same name as with yours).

$ lxd sql global “SELECT * from images_aliases;”
+----+----------------------------------------------+----------+-------------+------------+
| id |                     name                     | image_id | description | project_id |
+----+----------------------------------------------+----------+-------------+------------+
| 5  | Ubuntu 18.04 Bionic (amd64) with Salt minion | 157      |             | 1          |
+----+----------------------------------------------+----------+-------------+------------+

I then run the following. Here we change the field name for the row with id 5 (in my case).

$ lxd sql global 'UPDATE images_aliases SET name="properalias" WHERE id="5"'
Rows affected: 1

Now it looks proper.

$ lxc image alias list
+-------------+--------------+-------------+
|    ALIAS    | FINGERPRINT  | DESCRIPTION |
+-------------+--------------+-------------+
| properalias | ec5b3b3fc926 |             |
+-------------+--------------+-------------+

And, delete it.

$ lxc image alias delete properalias

thank you it worked.