API parse errors when lxc tags are null

ajpantuso

New Member
Mar 3, 2021
3
0
1
32
When testing the /nodes/{node}/lxc/{vmid}/config path for the API I noticed that a parse error is returned whenever the tags of a lxc instance are null.

Regardless of the error being returned the tags are updated correctly in both the null -> defined and defined -> null scenarios.

This same behavior is not reproducible for the equivalent qemu path.

Given that the lxc tags are null in the default state and the API throws 400 errors for these parse errors this is causing issues for clients expecting 2XX responses.

pveversion
pve-manager/6.3-3/eee5f901 (running kernel: 5.4.78-2-pve)

sudo pvesh get /nodes/.../lxc/1001/config --output-format json | json_pp
vm 1001 - unable to parse config: tags:
{
"tty" : 2,
"console" : 1,
"cpuunits" : 1024,
"swap" : 512,
"rootfs" : "vmstorage:vm-1001-disk-0,size=4G",
"protection" : 0,
"cpulimit" : "0",
"net0" : "...",
"hostname" : "...",
"onboot" : 0,
"memory" : 512,
"arch" : "amd64",
"ostype" : "ubuntu",
"digest" : "c8939fb8056655cc57e3cb997e126e211d3bf6ad",
"cmode" : "tty",
"cores" : 1
}
sudo pvesh set /nodes/.../lxc/1001/config -tags "test"
vm 1001 - unable to parse config: tags:

sudo pvesh get /nodes/.../lxc/1001/config --output-format json | json_pp
{
"console" : 1,
"memory" : 512,
"cpuunits" : 1024,
"tags" : "test",
"cores" : 1,
"swap" : 512,
"digest" : "98144008393b6c41d64942cbfc8e9a9b92e563b6",
"ostype" : "ubuntu",
"tty" : 2,
"hostname" : "...",
"protection" : 0,
"arch" : "amd64",
"cmode" : "tty",
"onboot" : 0,
"rootfs" : "vmstorage:vm-1001-disk-0,size=4G",
"net0" : "...",
"cpulimit" : "0"
}
sudo pvesh get /nodes/.../lxc/1001/config --output-format json | json_pp
{
"tags" : "test",
"cores" : 1,
"digest" : "98144008393b6c41d64942cbfc8e9a9b92e563b6",
"ostype" : "ubuntu",
"net0" : "...",
"console" : 1,
"hostname" : "...",
"protection" : 0,
"memory" : 512,
"arch" : "amd64",
"rootfs" : "vmstorage:vm-1001-disk-0,size=4G",
"cpuunits" : 1024,
"onboot" : 0,
"cmode" : "tty",
"tty" : 2,
"swap" : 512,
"cpulimit" : "0"
}

sudo pvesh set /nodes/.../lxc/1001/config -tags ""
vm 1001 - unable to parse config: tags:
 
Hi,
thanks for the report. It seems like we currently don't expect having no value for properties. I'll take a look.
 
FYI, I sent a patch for this and it should get fixed in a future version. It should be safe to ignore this specific warning until then, because as you already noted, updating the tags itself still works.
 
Awesome, I appreciate your work on this.
As a side note regarding tags specifically my assumption is they are meant to be provided as comma separated values, but I have not found any reference for allowable characters. (Though I have encountered some disallowed characters e.g. '=' and ':')
Is there a reference or spec available?
I have been trying to integrate tags in some ansible and terraform libraries and I think an explicit validation failure for tags would be better on VM creation as I doubt it's the first field an end user would check based on a 400 response.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!