public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Michal Fox <me@dualfroz.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH widget-toolkit] fix #7586: notification: check names of matchers and targets in the UI
Date: Tue,  6 Oct 2026 09:54:16 +0000	[thread overview]
Message-ID: <20261006095416.7-1-me@dualfroz.com> (raw)

The names of notification matchers and targets have to be safe IDs,
but only the name of webhook targets was checked in the UI, and that
without saying what is wrong. For all others, an invalid name, for
example one containing a space, was only rejected by the API with a
'parameter verification errors (400)' message, without saying which
characters are allowed.

Add a 'SafeId' vtype, which uses the existing safe ID regex and says
which characters are allowed, and use it for the names of matchers and
all target types.

Signed-off-by: Michal Fox <me@dualfroz.com>
---
Tested in the browser with the matcher and all target edit windows:
names with a space or a slash now show which characters are allowed,
valid names are still accepted.

Proxmox VE uses the stricter 'pve-configid' format for these names in
its API, so there, names starting with a digit or containing a dot are
still only rejected by the API.

 src/Toolkit.js                        | 9 +++++++++
 src/panel/GotifyEditPanel.js          | 1 +
 src/panel/SendmailEditPanel.js        | 1 +
 src/panel/SmtpEditPanel.js            | 1 +
 src/panel/WebhookEditPanel.js         | 2 +-
 src/window/NotificationMatcherEdit.js | 1 +
 6 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/src/Toolkit.js b/src/Toolkit.js
index bd31b3c..c1594b7 100644
--- a/src/Toolkit.js
+++ b/src/Toolkit.js
@@ -134,6 +134,15 @@ Ext.apply(Ext.form.field.VTypes, {
         ': ' +
         gettext('letter'),
 
+    SafeId: function (v) {
+        return Proxmox.Utils.safeIdRegex.test(v);
+    },
+    SafeIdText:
+        gettext('Allowed characters') +
+        ": 'A-Z', 'a-z', '0-9', '_', '-', '.'<br />" +
+        gettext('Must start with') +
+        ": 'A-Z', 'a-z', '0-9', '_'",
+
     HttpProxy: function (v) {
         return /^http:\/\/.*$/.test(v);
     },
diff --git a/src/panel/GotifyEditPanel.js b/src/panel/GotifyEditPanel.js
index 5e78e73..3e12323 100644
--- a/src/panel/GotifyEditPanel.js
+++ b/src/panel/GotifyEditPanel.js
@@ -15,6 +15,7 @@ Ext.define('Proxmox.panel.GotifyEditPanel', {
                 editable: '{isCreate}',
             },
             fieldLabel: gettext('Endpoint Name'),
+            vtype: 'SafeId',
             allowBlank: false,
         },
         {
diff --git a/src/panel/SendmailEditPanel.js b/src/panel/SendmailEditPanel.js
index a4de50c..81624ad 100644
--- a/src/panel/SendmailEditPanel.js
+++ b/src/panel/SendmailEditPanel.js
@@ -26,6 +26,7 @@ Ext.define('Proxmox.panel.SendmailEditPanel', {
                 editable: '{isCreate}',
             },
             fieldLabel: gettext('Endpoint Name'),
+            vtype: 'SafeId',
             allowBlank: false,
         },
         {
diff --git a/src/panel/SmtpEditPanel.js b/src/panel/SmtpEditPanel.js
index 37e4d51..8fafba9 100644
--- a/src/panel/SmtpEditPanel.js
+++ b/src/panel/SmtpEditPanel.js
@@ -51,6 +51,7 @@ Ext.define('Proxmox.panel.SmtpEditPanel', {
                 editable: '{isCreate}',
             },
             fieldLabel: gettext('Endpoint Name'),
+            vtype: 'SafeId',
             allowBlank: false,
         },
         {
diff --git a/src/panel/WebhookEditPanel.js b/src/panel/WebhookEditPanel.js
index 7980d8b..8854329 100644
--- a/src/panel/WebhookEditPanel.js
+++ b/src/panel/WebhookEditPanel.js
@@ -17,7 +17,7 @@ Ext.define('Proxmox.panel.WebhookEditPanel', {
                 editable: '{isCreate}',
             },
             fieldLabel: gettext('Endpoint Name'),
-            regex: Proxmox.Utils.safeIdRegex,
+            vtype: 'SafeId',
             allowBlank: false,
         },
     ],
diff --git a/src/window/NotificationMatcherEdit.js b/src/window/NotificationMatcherEdit.js
index a1d173c..d1b66a3 100644
--- a/src/window/NotificationMatcherEdit.js
+++ b/src/window/NotificationMatcherEdit.js
@@ -12,6 +12,7 @@ Ext.define('Proxmox.panel.NotificationMatcherGeneralPanel', {
                 editable: '{isCreate}',
             },
             fieldLabel: gettext('Matcher Name'),
+            vtype: 'SafeId',
             allowBlank: false,
         },
         {
-- 
2.43.0




                 reply	other threads:[~2026-10-06  9:54 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261006095416.7-1-me@dualfroz.com \
    --to=me@dualfroz.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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