From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id 9F7051FF0E1 for ; Mon, 16 Nov 2026 02:01:20 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 750BE21723; Mon, 16 Nov 2026 02:01:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1794790854; x=1795395654; darn=lists.proxmox.com; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=PvKwwRgy2J2yopbJKuuB9S/0mgkPdfrEDLEc9p3HfWE=; b=v17U43CjVS2RP0jH+j25CfxB7NTT2BNxZYCCb+jhF63q1WofopNvm7q1kml1WQhxgO vh0niQZNMzpB8Jg6y6C3CEptV7HEYSlxSom+4ZQRCULVOmRabWP0tnzOOy/JlCSN9STe 8qTJNCVhDgWcCK7dlgt7LZP5GCUsEBLy1ULi63cghYbkmmwmOhAWmip1l69f/gz8v4re oJB43Jol4MJoZTgSAisxfV1DKoQ/g9EbjJgp5TicwL4DZ1tLnE1SGJdMovzjQvq9cX2W qUMgpluvXvOANbcBStmxJrtYxKPcM6pY9FkAjVPD/GjZbgthnVTcS9rux9PhDYohVx4B 1Cxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794790854; x=1795395654; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=PvKwwRgy2J2yopbJKuuB9S/0mgkPdfrEDLEc9p3HfWE=; b=KpKV5irgsoB8wVtJo0Wbk0jRXNvVdPqJ8ZpIxmg39CPVLHgg0YU2cxyDV8vILVID6R zqBIBGmzDU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BzGV6t9/SvuY+ndQPFTp7Op505UD4zO74R6 X-Received: by 2002:a05:6102:2929:b0:7d2:f14a:bbb5 with SMTP id ada2fe7eead31-7d63162d990mr3094195137.5.1794790854220; Sun, 15 Nov 2026 17:00:54 -0800 (PST) From: Lucas Barros To: pve-devel@lists.proxmox.com Subject: [PATCH container v2 4/5] config: ignore an empty tag list when parsing Date: Sun, 15 Nov 2026 22:00:39 -0300 Message-ID: <20261116010040.90964-5-lucasbarros.kam@gmail.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20261116010040.90964-1-lucasbarros.kam@gmail.com> References: <1794390075.ol4qipttrq.astroid@yuna.none> <20261116010040.90964-1-lucasbarros.kam@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.058 Adjusted score from AWL reputation of From: address DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain DMARC_PASS -0.1 DMARC pass policy FREEMAIL_FROM 0.001 Sender email is commonly abused enduser mail provider RCVD_IN_DNSWL_NONE -0.0001 Sender listed at https://www.dnswl.org/, no trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: UEWITKJXQI7SW5IMIMUQZPIUP4LMHCVR X-Message-ID-Hash: UEWITKJXQI7SW5IMIMUQZPIUP4LMHCVR X-MailFrom: lucasbarros.kam@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Lucas Barros X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Configs of containers whose last tag was removed before the previous commit still contain a 'tags: ' line. It is read as a tag list consisting of a single space and shows up as such in the API, while a 'tags:' line without the trailing space is reported as a line that cannot be parsed. An empty tag list is the same as having no tags, so skip such a line when parsing, like an unset option. Use split_list() to decide whether the list is empty, so a value consisting only of delimiters is handled the same way. Configs that contain such a line lose it on the next write. Suggested-by: Fabian Grünbichler Signed-off-by: Lucas Barros --- changes since v1: * new patch, replaces the writer change of v1 The new subtest builds the config in a string, so the 'tags: ' case with the trailing space is covered without trailing whitespace in the test file. This patch was prepared with the help of an LLM based coding assistant; I reviewed the change and ran the tests mentioned in the cover letter myself. src/PVE/LXC/Config.pm | 3 +++ src/test/config_tests.pl | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/PVE/LXC/Config.pm b/src/PVE/LXC/Config.pm index 7052509..2d47228 100644 --- a/src/PVE/LXC/Config.pm +++ b/src/PVE/LXC/Config.pm @@ -1199,6 +1199,9 @@ sub parse_pct_config { } else { $handle_error->("vm $vmid - property 'delete' is only allowed in [pve:pending]\n"); } + } elsif ($line =~ m/^tags:\s*(.*?)\s*$/ && !PVE::Tools::split_list($1)) { + # an empty tag list is the same as no tags + next; } elsif ($line =~ m/^([a-z][a-z_]*\d*):\s*(.+?)\s*$/) { my $key = $1; my $value = $2; diff --git a/src/test/config_tests.pl b/src/test/config_tests.pl index fbf1771..855681e 100755 --- a/src/test/config_tests.pl +++ b/src/test/config_tests.pl @@ -151,4 +151,25 @@ subtest 'parsing drops keys outside of the schema' => sub { is($conf->{memory}, 'invalid', 'invalid value of a known key is kept'); }; +subtest 'parsing ignores an empty tag list' => sub { + # 'tags: ' with the trailing space is what got written after removing the last tag + for my $tags ('', ' ', ' ;, ') { + my $raw = "hostname: ct100\ntags:$tags\n"; + + my $conf; + { + my $warnings = ''; + local $SIG{__WARN__} = sub { $warnings .= $_[0] }; + $conf = PVE::LXC::Config::parse_pct_config('/lxc/100.conf', $raw); + is($warnings, '', "no warning for 'tags:$tags'"); + } + + is($conf->{hostname}, 'ct100', 'valid key is kept'); + ok(!exists($conf->{tags}), "'tags:$tags' is dropped"); + } + + my $conf = PVE::LXC::Config::parse_pct_config('/lxc/100.conf', "tags: a;b\n"); + is($conf->{tags}, 'a;b', 'non-empty tag list is kept'); +}; + done_testing(); -- 2.50.1 (Apple Git-155)