public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH 0/5] fix #7077: Improve ID validation error messages
@ 2026-01-21 10:32 Arthur Bied-Charreton
  2026-01-21 10:32 ` [pve-devel] [PATCH pve-common] fix #7077: Improve error message for IDs shorter than 2 characters Arthur Bied-Charreton
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Arthur Bied-Charreton @ 2026-01-21 10:32 UTC (permalink / raw)
  To: pve-devel

This series improves error messages for ID validation by adding explicit
length checks before regex validations.

The regex patterns used in different ID validators have implicit length
requirements that were often not reflected in the error messages.

pve-network
    src/PVE/Network/SDN/Controllers/Plugin.pm | 12 +++++++++++-
    src/PVE/Network/SDN/Dns/Plugin.pm         |  5 +++++
    src/PVE/Network/SDN/Fabrics.pm            |  5 +++++
    src/PVE/Network/SDN/Ipams/Plugin.pm       |  5 +++++
    src/PVE/Network/SDN/VnetPlugin.pm         | 12 +++++++++++-
    src/PVE/Network/SDN/Zones/Plugin.pm       | 12 +++++++++++-
    6 files changed, 48 insertions(+), 3 deletions(-)

proxmox
    pve-api-types/src/types/verifiers.rs | 4 ++++
    1 file changed, 4 insertions(+)

pve-storage
    src/PVE/Storage/Plugin.pm | 5 +++++
    1 file changed, 5 insertions(+)

pve-common
    src/PVE/JSONSchema.pm | 5 +++++
    2 files changed, 6 insertions(+), 5 deletions(-)


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [pve-devel] [PATCH pve-common] fix #7077: Improve error message for IDs shorter than 2 characters
  2026-01-21 10:32 [pve-devel] [PATCH 0/5] fix #7077: Improve ID validation error messages Arthur Bied-Charreton
@ 2026-01-21 10:32 ` Arthur Bied-Charreton
  2026-01-21 18:00   ` [pve-devel] applied: " Thomas Lamprecht
  2026-01-21 10:32 ` [pve-devel] [PATCH pve-storage] fix #7077: Improve error message for IDS " Arthur Bied-Charreton
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 7+ messages in thread
From: Arthur Bied-Charreton @ 2026-01-21 10:32 UTC (permalink / raw)
  To: pve-devel

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@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


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [pve-devel] [PATCH pve-storage] fix #7077: Improve error message for IDS shorter than 2 characters
  2026-01-21 10:32 [pve-devel] [PATCH 0/5] fix #7077: Improve ID validation error messages Arthur Bied-Charreton
  2026-01-21 10:32 ` [pve-devel] [PATCH pve-common] fix #7077: Improve error message for IDs shorter than 2 characters Arthur Bied-Charreton
@ 2026-01-21 10:32 ` Arthur Bied-Charreton
  2026-01-21 10:32 ` [pve-devel] [PATCH proxmox] fix #7077: Improve error message for SDN IDs " Arthur Bied-Charreton
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Arthur Bied-Charreton @ 2026-01-21 10:32 UTC (permalink / raw)
  To: pve-devel

The regex in Storage::parse_lvm_name 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@proxmox.com>
---
 src/PVE/Storage/Plugin.pm | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/PVE/Storage/Plugin.pm b/src/PVE/Storage/Plugin.pm
index 6f3d691..58f714c 100644
--- a/src/PVE/Storage/Plugin.pm
+++ b/src/PVE/Storage/Plugin.pm
@@ -333,6 +333,11 @@ PVE::JSONSchema::register_format('pve-storage-vgname', \&parse_lvm_name);
 sub parse_lvm_name {
     my ($name, $noerr) = @_;
 
+    if (length($name) < 2) {
+        return undef if $noerr;
+        die "lvm name '$name' can't be shorter than 2 characters\n";
+    }
+
     if ($name !~ m/^[a-z0-9][a-z0-9\-\_\.]*[a-z0-9]$/i) {
         return undef if $noerr;
         die "lvm name '$name' contains illegal characters\n";
-- 
2.47.3


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [pve-devel] [PATCH proxmox] fix #7077: Improve error message for SDN IDs shorter than 2 characters
  2026-01-21 10:32 [pve-devel] [PATCH 0/5] fix #7077: Improve ID validation error messages Arthur Bied-Charreton
  2026-01-21 10:32 ` [pve-devel] [PATCH pve-common] fix #7077: Improve error message for IDs shorter than 2 characters Arthur Bied-Charreton
  2026-01-21 10:32 ` [pve-devel] [PATCH pve-storage] fix #7077: Improve error message for IDS " Arthur Bied-Charreton
@ 2026-01-21 10:32 ` Arthur Bied-Charreton
  2026-01-21 10:32 ` [pve-devel] [PATCH pve-network 1/2] fix #7077: Improve error messages for ID length mismatch Arthur Bied-Charreton
  2026-01-21 10:32 ` [pve-devel] [PATCH pve-network 2/2] fix #7077: Respect noerr flag in SDN ID validation Arthur Bied-Charreton
  4 siblings, 0 replies; 7+ messages in thread
From: Arthur Bied-Charreton @ 2026-01-21 10:32 UTC (permalink / raw)
  To: pve-devel

The regex in verify_sdn_id implicitly requires at least 2 characters, but
shorter IDs only failed with "contains illegal characters". Now return a
clearer error message for this case.

Signed-off-by: Arthur Bied-Charreton <a.bied-charreton@proxmox.com>
---
 pve-api-types/src/types/verifiers.rs | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/pve-api-types/src/types/verifiers.rs b/pve-api-types/src/types/verifiers.rs
index c45063b5..aa6c7f40 100644
--- a/pve-api-types/src/types/verifiers.rs
+++ b/pve-api-types/src/types/verifiers.rs
@@ -269,6 +269,10 @@ pub fn verify_sdn_id(s: &str) -> Result<(), Error> {
         bail!("SDN ID cannot be longer than 8 characters")
     }
 
+    if s.len() < 2 {
+        bail!("SDN ID cannot be shorter than 2 characters");
+    }
+
     if !SDN_ID.is_match(s) {
         bail!("SDN ID contains illegal characters");
     }
-- 
2.47.3


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [pve-devel] [PATCH pve-network 1/2] fix #7077: Improve error messages for ID length mismatch
  2026-01-21 10:32 [pve-devel] [PATCH 0/5] fix #7077: Improve ID validation error messages Arthur Bied-Charreton
                   ` (2 preceding siblings ...)
  2026-01-21 10:32 ` [pve-devel] [PATCH proxmox] fix #7077: Improve error message for SDN IDs " Arthur Bied-Charreton
@ 2026-01-21 10:32 ` Arthur Bied-Charreton
  2026-01-21 10:32 ` [pve-devel] [PATCH pve-network 2/2] fix #7077: Respect noerr flag in SDN ID validation Arthur Bied-Charreton
  4 siblings, 0 replies; 7+ messages in thread
From: Arthur Bied-Charreton @ 2026-01-21 10:32 UTC (permalink / raw)
  To: pve-devel

Add explicit length checks to ID validation functions to provide clearer
error messages in case of length mismatches

Signed-off-by: Arthur Bied-Charreton <a.bied-charreton@proxmox.com>
---
 src/PVE/Network/SDN/Controllers/Plugin.pm | 5 +++++
 src/PVE/Network/SDN/Dns/Plugin.pm         | 5 +++++
 src/PVE/Network/SDN/Fabrics.pm            | 5 +++++
 src/PVE/Network/SDN/Ipams/Plugin.pm       | 5 +++++
 src/PVE/Network/SDN/VnetPlugin.pm         | 5 +++++
 src/PVE/Network/SDN/Zones/Plugin.pm       | 5 +++++
 6 files changed, 30 insertions(+)

diff --git a/src/PVE/Network/SDN/Controllers/Plugin.pm b/src/PVE/Network/SDN/Controllers/Plugin.pm
index d70e518..f117f28 100644
--- a/src/PVE/Network/SDN/Controllers/Plugin.pm
+++ b/src/PVE/Network/SDN/Controllers/Plugin.pm
@@ -30,6 +30,11 @@ PVE::JSONSchema::register_format('pve-sdn-controller-id', \&parse_sdn_controller
 sub parse_sdn_controller_id {
     my ($id, $noerr) = @_;
 
+    if (length($id) < 2) {
+        return undef if $noerr;
+        die "controller ID '$id' can't be shorter than 2 characters\n";
+    }
+
     if ($id !~ m/^[a-z][a-z0-9_-]*[a-z0-9]$/i) {
         return undef if $noerr;
         die "controller ID '$id' contains illegal characters\n";
diff --git a/src/PVE/Network/SDN/Dns/Plugin.pm b/src/PVE/Network/SDN/Dns/Plugin.pm
index 2864d4c..68a07fa 100644
--- a/src/PVE/Network/SDN/Dns/Plugin.pm
+++ b/src/PVE/Network/SDN/Dns/Plugin.pm
@@ -32,6 +32,11 @@ PVE::JSONSchema::register_format('pve-sdn-dns-id', \&parse_sdn_dns_id);
 sub parse_sdn_dns_id {
     my ($id, $noerr) = @_;
 
+    if (length($id) < 2) {
+        return undef if $noerr;
+        die "dns ID '$id' can't be shorter than 2 characters\n";
+    }
+
     if ($id !~ m/^[a-z][a-z0-9]*[a-z0-9]$/i) {
         return undef if $noerr;
         die "dns ID '$id' contains illegal characters\n";
diff --git a/src/PVE/Network/SDN/Fabrics.pm b/src/PVE/Network/SDN/Fabrics.pm
index d90992a..b18ac7d 100644
--- a/src/PVE/Network/SDN/Fabrics.pm
+++ b/src/PVE/Network/SDN/Fabrics.pm
@@ -13,6 +13,11 @@ PVE::JSONSchema::register_format(
     sub {
         my ($id, $noerr) = @_;
 
+        if (length($id) > 8) {
+            return undef if $noerr;
+            die "Fabric ID '$id' can't be longer than 8 characters\n";
+        }
+
         if ($id !~ m/^[a-zA-Z0-9][a-zA-Z0-9-]{0,6}[a-zA-Z0-9]?$/i) {
             return undef if $noerr;
             die "Fabric ID '$id' contains illegal characters\n";
diff --git a/src/PVE/Network/SDN/Ipams/Plugin.pm b/src/PVE/Network/SDN/Ipams/Plugin.pm
index a986a92..10aabea 100644
--- a/src/PVE/Network/SDN/Ipams/Plugin.pm
+++ b/src/PVE/Network/SDN/Ipams/Plugin.pm
@@ -33,6 +33,11 @@ PVE::JSONSchema::register_format('pve-sdn-ipam-id', \&parse_sdn_ipam_id);
 sub parse_sdn_ipam_id {
     my ($id, $noerr) = @_;
 
+    if (length($id) < 2) {
+        return undef if $noerr;
+        die "ipam ID '$id' can't be shorter than 2 characters\n";
+    }
+
     if ($id !~ m/^[a-z][a-z0-9]*[a-z0-9]$/i) {
         return undef if $noerr;
         die "ipam ID '$id' contains illegal characters\n";
diff --git a/src/PVE/Network/SDN/VnetPlugin.pm b/src/PVE/Network/SDN/VnetPlugin.pm
index 717438c..a191af1 100644
--- a/src/PVE/Network/SDN/VnetPlugin.pm
+++ b/src/PVE/Network/SDN/VnetPlugin.pm
@@ -30,6 +30,11 @@ PVE::JSONSchema::register_format('pve-sdn-vnet-id', \&parse_sdn_vnet_id);
 sub parse_sdn_vnet_id {
     my ($id, $noerr) = @_;
 
+    if (length($id) < 2) {
+        return undef if $noerr;
+        die "vnet ID '$id' can't be shorter than 2 characters\n";
+    }
+
     if ($id !~ m/^[a-z][a-z0-9]*[a-z0-9]$/i) {
         return undef if $noerr;
         die "vnet ID '$id' contains illegal characters\n";
diff --git a/src/PVE/Network/SDN/Zones/Plugin.pm b/src/PVE/Network/SDN/Zones/Plugin.pm
index 826ebdf..14e2634 100644
--- a/src/PVE/Network/SDN/Zones/Plugin.pm
+++ b/src/PVE/Network/SDN/Zones/Plugin.pm
@@ -32,6 +32,11 @@ PVE::JSONSchema::register_format('pve-sdn-zone-id', \&parse_sdn_zone_id);
 sub parse_sdn_zone_id {
     my ($id, $noerr) = @_;
 
+    if (length($id) < 2) {
+        return undef if $noerr;
+        die "zone ID '$id' can't be shorter than 2 characters\n";
+    }
+
     if ($id !~ m/^[a-z][a-z0-9]*[a-z0-9]$/i) {
         return undef if $noerr;
         die "zone ID '$id' contains illegal characters\n";
-- 
2.47.3


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [pve-devel] [PATCH pve-network 2/2] fix #7077: Respect noerr flag in SDN ID validation
  2026-01-21 10:32 [pve-devel] [PATCH 0/5] fix #7077: Improve ID validation error messages Arthur Bied-Charreton
                   ` (3 preceding siblings ...)
  2026-01-21 10:32 ` [pve-devel] [PATCH pve-network 1/2] fix #7077: Improve error messages for ID length mismatch Arthur Bied-Charreton
@ 2026-01-21 10:32 ` Arthur Bied-Charreton
  4 siblings, 0 replies; 7+ messages in thread
From: Arthur Bied-Charreton @ 2026-01-21 10:32 UTC (permalink / raw)
  To: pve-devel

The length checks in parse_sdn*_id functions would ignore the '$noerr'
parameter and always die on too-long IDs.

Also fixes grammar in error messages ("more length" -> "longer").

Signed-off-by: Arthur Bied-Charreton <a.bied-charreton@proxmox.com>
---
 src/PVE/Network/SDN/Controllers/Plugin.pm | 7 ++++++-
 src/PVE/Network/SDN/VnetPlugin.pm         | 7 ++++++-
 src/PVE/Network/SDN/Zones/Plugin.pm       | 7 ++++++-
 3 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/src/PVE/Network/SDN/Controllers/Plugin.pm b/src/PVE/Network/SDN/Controllers/Plugin.pm
index f117f28..52e385c 100644
--- a/src/PVE/Network/SDN/Controllers/Plugin.pm
+++ b/src/PVE/Network/SDN/Controllers/Plugin.pm
@@ -39,7 +39,12 @@ sub parse_sdn_controller_id {
         return undef if $noerr;
         die "controller ID '$id' contains illegal characters\n";
     }
-    die "controller ID '$id' can't be more length than 64 characters\n" if length($id) > 64;
+
+    if (length($id) > 64) {
+        return undef if $noerr;
+        die "controller ID '$id' can't be longer than 64 characters\n";
+    }
+
     return $id;
 }
 
diff --git a/src/PVE/Network/SDN/VnetPlugin.pm b/src/PVE/Network/SDN/VnetPlugin.pm
index a191af1..6c5f997 100644
--- a/src/PVE/Network/SDN/VnetPlugin.pm
+++ b/src/PVE/Network/SDN/VnetPlugin.pm
@@ -39,7 +39,12 @@ sub parse_sdn_vnet_id {
         return undef if $noerr;
         die "vnet ID '$id' contains illegal characters\n";
     }
-    die "vnet ID '$id' can't be more length than 8 characters\n" if length($id) > 8;
+
+    if (length($id) > 8) {
+        return undef if $noerr;
+        die "vnet ID '$id' can't be longer than 8 characters\n";
+    }
+
     return $id;
 }
 
diff --git a/src/PVE/Network/SDN/Zones/Plugin.pm b/src/PVE/Network/SDN/Zones/Plugin.pm
index 14e2634..5592a09 100644
--- a/src/PVE/Network/SDN/Zones/Plugin.pm
+++ b/src/PVE/Network/SDN/Zones/Plugin.pm
@@ -41,7 +41,12 @@ sub parse_sdn_zone_id {
         return undef if $noerr;
         die "zone ID '$id' contains illegal characters\n";
     }
-    die "zone ID '$id' can't be more length than 8 characters\n" if length($id) > 8;
+
+    if (length($id) > 8) {
+        return undef if $noerr;
+        die "zone ID '$id' can't be longer than 8 characters\n";
+    }
+
     return $id;
 }
 
-- 
2.47.3


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [pve-devel] applied: [PATCH pve-common] fix #7077: Improve error message for IDs shorter than 2 characters
  2026-01-21 10:32 ` [pve-devel] [PATCH pve-common] fix #7077: Improve error message for IDs shorter than 2 characters Arthur Bied-Charreton
@ 2026-01-21 18:00   ` Thomas Lamprecht
  0 siblings, 0 replies; 7+ messages in thread
From: Thomas Lamprecht @ 2026-01-21 18:00 UTC (permalink / raw)
  To: pve-devel, Arthur Bied-Charreton

On Wed, 21 Jan 2026 11:32:29 +0100, Arthur Bied-Charreton wrote:
> 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.
> 
> 

Change looks alright as do the meta info like commit message, nice work!

Applied this one already, thanks!

[1/1] fix #7077: Improve error message for IDs shorter than 2 characters
      commit: d43c573d87dd374b200ec6366ad79175dc586012


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-01-21 18:01 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-21 10:32 [pve-devel] [PATCH 0/5] fix #7077: Improve ID validation error messages Arthur Bied-Charreton
2026-01-21 10:32 ` [pve-devel] [PATCH pve-common] fix #7077: Improve error message for IDs shorter than 2 characters Arthur Bied-Charreton
2026-01-21 18:00   ` [pve-devel] applied: " Thomas Lamprecht
2026-01-21 10:32 ` [pve-devel] [PATCH pve-storage] fix #7077: Improve error message for IDS " Arthur Bied-Charreton
2026-01-21 10:32 ` [pve-devel] [PATCH proxmox] fix #7077: Improve error message for SDN IDs " Arthur Bied-Charreton
2026-01-21 10:32 ` [pve-devel] [PATCH pve-network 1/2] fix #7077: Improve error messages for ID length mismatch Arthur Bied-Charreton
2026-01-21 10:32 ` [pve-devel] [PATCH pve-network 2/2] fix #7077: Respect noerr flag in SDN ID validation Arthur Bied-Charreton

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