From: "Lukas Wagner" <l.wagner@proxmox.com>
To: "Dominik Csapak" <d.csapak@proxmox.com>, <pdm-devel@lists.proxmox.com>
Subject: Re: [PATCH datacenter-manager] ui: auto-installer: correctly validate numeric counters in form
Date: Tue, 26 May 2026 16:18:59 +0200 [thread overview]
Message-ID: <DISO9LRYGWPP.2KOHQHQT41TJK@proxmox.com> (raw)
In-Reply-To: <20260526140647.3594593-1-d.csapak@proxmox.com>
On Tue May 26, 2026 at 4:06 PM CEST, Dominik Csapak wrote:
> field values are usually strings, so when a user entered any number
> here, it would display:
>
> invalid value: "1"
>
> since only numbers were expected here.
>
> To fix this, simply parse strings into numbers.
>
> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
> ---
> ui/src/remotes/auto_installer/prepared_answer_form.rs | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/ui/src/remotes/auto_installer/prepared_answer_form.rs b/ui/src/remotes/auto_installer/prepared_answer_form.rs
> index d932efe7..b5c59626 100644
> --- a/ui/src/remotes/auto_installer/prepared_answer_form.rs
> +++ b/ui/src/remotes/auto_installer/prepared_answer_form.rs
> @@ -1040,7 +1040,12 @@ fn kv_list_to_template_counter_map_validate(v: &Vec<(String, Value)>) -> Result<
> let mut map = BTreeMap::<String, i32>::new();
> for (k, v) in v {
> if TEMPLATE_COUNTER_NAME_REGEX.is_match(k) {
> - match v.as_i64().and_then(|v| v.try_into().ok()) {
> + let value = match v {
> + Value::Number(number) => number.as_i64(),
> + Value::String(text) => text.parse().ok(),
> + _ => None,
> + };
> + match value.and_then(|v| v.try_into().ok()) {
> Some(v) => {
> map.insert(k.clone(), v);
> }
I'm still getting a 'invalid value: ""' when adding a new template
counter, the error goes away once I edit the "Current Value" (e.g delete
the '0' and type in '0' again).
Can you reproduce this?
next prev parent reply other threads:[~2026-05-26 14:19 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-26 14:06 [PATCH datacenter-manager] ui: auto-installer: correctly validate numeric counters in form Dominik Csapak
2026-05-26 14:18 ` Lukas Wagner [this message]
2026-05-26 14:25 ` Dominik Csapak
2026-05-26 14:29 ` Thomas Lamprecht
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=DISO9LRYGWPP.2KOHQHQT41TJK@proxmox.com \
--to=l.wagner@proxmox.com \
--cc=d.csapak@proxmox.com \
--cc=pdm-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