[pve-devel] [PATCH pve-common] fix #7077: Improve error message for IDs shorter than 2 characters

Arthur Bied-Charreton a.bied-charreton at proxmox.com
Wed Jan 21 11:32:29 CET 2026


The regex in JSONSchema::parse_id requires at least 2 characters, but
shorter IDs only failed with "contains illegal characters". Add explicit
length check to return a clearer error message in this case.

Signed-off-by: Arthur Bied-Charreton <a.bied-charreton at proxmox.com>
---
 src/PVE/JSONSchema.pm | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/PVE/JSONSchema.pm b/src/PVE/JSONSchema.pm
index 0c9bb82..17e7126 100644
--- a/src/PVE/JSONSchema.pm
+++ b/src/PVE/JSONSchema.pm
@@ -289,6 +289,11 @@ sub parse_acme_plugin_id {
 sub parse_id {
     my ($id, $type, $noerr) = @_;
 
+    if (length($id) < 2) {
+        return undef if $noerr;
+        die "$type ID '$id' cannot be shorter than 2 characters\n";
+    }
+
     if ($id !~ m/^[a-z][a-z0-9\-\_\.]*[a-z0-9]$/i) {
         return undef if $noerr;
         die "$type ID '$id' contains illegal characters\n";
-- 
2.47.3




More information about the pve-devel mailing list