public inbox for pdm-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [PATCH datacenter-manager] ui: auto-installer: correctly validate numeric counters in form
@ 2026-05-26 14:06 Dominik Csapak
  2026-05-26 14:18 ` Lukas Wagner
  2026-05-26 14:29 ` Thomas Lamprecht
  0 siblings, 2 replies; 4+ messages in thread
From: Dominik Csapak @ 2026-05-26 14:06 UTC (permalink / raw)
  To: pdm-devel

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);
                 }
-- 
2.47.3





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

* Re: [PATCH datacenter-manager] ui: auto-installer: correctly validate numeric counters in form
  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
  2026-05-26 14:25   ` Dominik Csapak
  2026-05-26 14:29 ` Thomas Lamprecht
  1 sibling, 1 reply; 4+ messages in thread
From: Lukas Wagner @ 2026-05-26 14:18 UTC (permalink / raw)
  To: Dominik Csapak, pdm-devel

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?




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

* Re: [PATCH datacenter-manager] ui: auto-installer: correctly validate numeric counters in form
  2026-05-26 14:18 ` Lukas Wagner
@ 2026-05-26 14:25   ` Dominik Csapak
  0 siblings, 0 replies; 4+ messages in thread
From: Dominik Csapak @ 2026-05-26 14:25 UTC (permalink / raw)
  To: Lukas Wagner, pdm-devel



On 5/26/26 4:18 PM, Lukas Wagner wrote:
> 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?


yep, true. i'll see what i can do




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

* Re: [PATCH datacenter-manager] ui: auto-installer: correctly validate numeric counters in form
  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
@ 2026-05-26 14:29 ` Thomas Lamprecht
  1 sibling, 0 replies; 4+ messages in thread
From: Thomas Lamprecht @ 2026-05-26 14:29 UTC (permalink / raw)
  To: pdm-devel, Dominik Csapak

On Tue, 26 May 2026 16:06:42 +0200, 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.
> 
> [...]

Applied, thanks!

[1/1] ui: auto-installer: correctly validate numeric counters in form
      commit: 060fcee43159768d83521b66b1bb120eb4e52219




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

end of thread, other threads:[~2026-05-26 14:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2026-05-26 14:25   ` Dominik Csapak
2026-05-26 14:29 ` Thomas Lamprecht

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