public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Thomas Lamprecht <t.lamprecht@proxmox.com>
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>,
	Fiona Ebner <f.ebner@proxmox.com>
Subject: Re: [pve-devel] [PATCH stable-7+master manager] ui: vm selector: handle empty string gracefully
Date: Thu, 6 Jul 2023 18:16:17 +0200	[thread overview]
Message-ID: <5c9ba76f-e505-822f-237d-b2dcdce347d2@proxmox.com> (raw)
In-Reply-To: <20230706135125.60221-1-f.ebner@proxmox.com>

Am 06/07/2023 um 15:51 schrieb Fiona Ebner:
> which is passed by the backup job window when using selection mode
> 'all', would be converted to [""] and wrongly add an entry with VMID
> 0 because the item "" could not be found in the store.
> 
> Reported in the community forum:
> https://forum.proxmox.com/threads/130164/
> 
> Fixes: 7a5ca76a ("fix #4239: ui: show selected but non-existing vmids in backup edit")
> Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
> ---
>  www/manager6/form/VMSelector.js | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/www/manager6/form/VMSelector.js b/www/manager6/form/VMSelector.js
> index 4c0bba13..bf2c8df7 100644
> --- a/www/manager6/form/VMSelector.js
> +++ b/www/manager6/form/VMSelector.js
> @@ -162,7 +162,7 @@ Ext.define('PVE.form.VMSelector', {
>      setValue: function(value) {
>  	let me = this;
>  	if (!Ext.isArray(value)) {
> -	    value = value.split(',');
> +	    value = value === '' ? [] : value.split(',');

more future proof would be doing it (also) on the call sites, as then future callers
are also guarded against it, e.g. something like:

diff --git a/www/manager6/form/VMSelector.js b/www/manager6/form/VMSelector.js
index bf2c8df7..076360ec 100644
--- a/www/manager6/form/VMSelector.js
+++ b/www/manager6/form/VMSelector.js
@@ -135,7 +135,7 @@ Ext.define('PVE.form.VMSelector', {
        let notFound = [];
        let selection = value.map(item => {
            let found = store.findRecord('vmid', item, 0, false, true, true);
-           if (!found) {
+           if (!found && item !== '') {
                notFound.push(item);
            }
            return found;

or if we want to go above and beyond we could even do a regex match for /^[1-9][0-9]{2,}$/
while more expensive even thousands of guests should not really add a noticeable delay,
but just mentioning it for completeness sake.




  reply	other threads:[~2023-07-06 16:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-06 13:51 Fiona Ebner
2023-07-06 16:16 ` Thomas Lamprecht [this message]
2023-07-07  7:41   ` Fiona Ebner

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=5c9ba76f-e505-822f-237d-b2dcdce347d2@proxmox.com \
    --to=t.lamprecht@proxmox.com \
    --cc=f.ebner@proxmox.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