public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [PATCH common] fix #5607: json schema: describe the allowed characters of configuration IDs
@ 2026-11-26  9:17 Michal Fox
  0 siblings, 0 replies; only message in thread
From: Michal Fox @ 2026-11-26  9:17 UTC (permalink / raw)
  To: pve-devel

An ID that does not match the pve-configid format, for example the name
of a resource mapping, is rejected with just "invalid configuration ID",
so users have to guess what is wrong with it. Spell out the rule in the
error message and add a test for it.

Signed-off-by: Michal Fox <me@dualfroz.com>
---
tested with make check, the new test fails without the change

 src/PVE/JSONSchema.pm | 3 ++-
 test/format_test.pl   | 3 +++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/PVE/JSONSchema.pm b/src/PVE/JSONSchema.pm
index 41210b7..5d2b7d4 100644
--- a/src/PVE/JSONSchema.pm
+++ b/src/PVE/JSONSchema.pm
@@ -256,7 +256,8 @@ sub pve_verify_configid {
 
     if ($id !~ m/^$CONFIGID_RE\z/) {
         return undef if $noerr;
-        die "invalid configuration ID '$id'\n";
+        die "invalid configuration ID '$id' - must start with a letter and be followed by"
+            . " at least one letter, digit, '-' or '_'\n";
     }
     return $id;
 }
diff --git a/test/format_test.pl b/test/format_test.pl
index 2b9460d..f2993a9 100755
--- a/test/format_test.pl
+++ b/test/format_test.pl
@@ -26,6 +26,9 @@ foreach my $id (@$invalid_configids) {
     is(PVE::JSONSchema::pve_verify_configid($id, $noerr), undef, 'invalid configid');
 }
 
+eval { PVE::JSONSchema::pve_verify_configid('1a') };
+like($@, qr/must start with a letter/, 'invalid configid error describes the allowed characters');
+
 # test some string rendering
 my $render_data = [
     ["timestamp", 0, undef, "1970-01-01 01:00:00"],
-- 
2.43.0




^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-26  9:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-26  9:17 [PATCH common] fix #5607: json schema: describe the allowed characters of configuration IDs Michal Fox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal