Bug 1455944
| Summary: | integer field incorrectly allows text when entering text after first entering a valid integer | ||
|---|---|---|---|
| Product: | [oVirt] ovirt-engine | Reporter: | Tomas Jelinek <tjelinek> |
| Component: | Frontend.WebAdmin | Assignee: | rszwajko |
| Status: | CLOSED CURRENTRELEASE | QA Contact: | Ivana Saranova <isaranov> |
| Severity: | medium | Docs Contact: | |
| Priority: | medium | ||
| Version: | 4.2.0 | CC: | bugs, gshereme, lleistne, mgoldboi, michal.skrivanek, rszwajko, sgratch, vszocs |
| Target Milestone: | ovirt-4.4.1 | Keywords: | Reopened |
| Target Release: | --- | Flags: | pm-rhel:
ovirt-4.4+
sgratch: planning_ack? sgratch: devel_ack+ lleistne: testing_ack+ |
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
| Whiteboard: | |||
| Fixed In Version: | rhv-4.4.0-36 | Doc Type: | If docs needed, set a value |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2020-07-08 08:24:40 UTC | Type: | Bug |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | UX | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
| Embargoed: | |||
| Bug Depends On: | |||
| Bug Blocks: | 1438492, 1588049 | ||
|
Description
Tomas Jelinek
2017-05-26 13:49:50 UTC
(In reply to Tomas Jelinek from comment #0) > The problem is that it works like this: > - have a text field which can contain only ints (e.g. is using the > ToIntEntityModelParser) > - set a valid value into it (e.g. 5) > - leave the field (the model will be set to have the value 5) > - enter the field again and set the value to "aaa" > - leave the field (the ToIntEntityModelParser will throw ParseException > which will be caught by EntityModelTextBox and mark the field as invalid - > red border and tooltip) > - submit the dialog > - the submit passes because the model has value 5 from the previous edit and > the validate of it passes. There are two ways to solve this: 1, allow users of such input widget (EntityModelTextBox) to enter non-numeric characters (like "aaa") and in case of parse error, reset the value to null (i.e. not a number) 2, disallow users of such input widget to enter non-numeric characters oVirt 91182 is a workaround for one specific use-case and does not fix the infra-level problem Unfortunately we don't have capacity to work on this. Re-opening since we handled a similar issue and assume we can fix this easily The fix follows suggestion no 1 > 1, allow users of such input widget (EntityModelTextBox) to enter non-numeric characters (like "aaa") and in case of parse error, reset the value to null (i.e. not a number) The fix is based on changes introduced in https://bugzilla.redhat.com/1168315 however it reverts the part that limited model update - now the model will be (again) updated with every editor change. Editor in invalid state will: 1. update model with null. This prevents valid but stale state. 2. ignore null values coming from the model. This prevents replacing invalid user input with null coming back from the model. 3. ignore results of model-level validation. Editor-level validation has higher priority. Note that the bug scenario described in this issue will still apply in case of optional field: editor might be visually in error state but the model will contain null value (which is in this case a valid value). IMHO this behaviour is OK: we don't want to force user to clean all optional fields before submitting a form. The fix is based on changes introduced in https://bugzilla.redhat.com/1168315 so the scenario described there are useful for regression. Additional scenario from https://gerrit.ovirt.org/#/c/37244 ( by Alexander Wels) > We are going from always setting it to only setting it if the EDITOR is not marked invalid. This is to prevent the following scenario. > 1. I enter an invalid value, click ok but some other field is invalid. > 2. I change the value to be valid, click ok but some other field is invalid. > 3. I change the value to be invalid again, if I always write the value > (in this case it would be null because the editor cannot parse the value), > then it will fire a change event, and it will wipe out what I entered it the editor. > Which is a bad user experience since in step 1 it didn't wipe out the value. Workarounds i.e. https://bugzilla.redhat.com/1514374 should be removed under separate issue after this fixed will be accepted and merged. Thanks for the fix! The change looks good to me. One more possible follow-up is to use pattern-based HTML input validation [1], for example: <input type="text" pattern="[0-9]*" /> Such pattern would be enforced on DOM level, i.e. JS/GWT code would only receive values matching the pattern. [1] https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input#htmlattrdefpattern This bug is targeted to 4.4.1 and in modified state. can we re-target to 4.4.0 and move to QA? (In reply to Sandro Bonazzola from comment #7) > This bug is targeted to 4.4.1 and in modified state. can we re-target to > 4.4.0 and move to QA? Sure, done Steps:
1) Find text field that accepts only integers and is not optional ('Edit VM' -> 'System' -> 'Total Virtual CPUs')
2) Write random number into it (e.g. 5)
3) Leave the field
4) Come back to the field and edit it to non-integer value (e.g. 'aaa')
5) Submit the changes (Should not pass)
6) Change the value back to the correct value (e.g. 1)
7) Submit the changes (Should pass)
Result:
The text field has red borders suggesting that the value inside is incorrect and trying to submit this form does not pass. However, after changing the incorrect value back to the correct value, the form still cannot be submitted - the 'System' tab has red font, but there are no red text fields in it. When I hover over the text field that has now correct value, tooltip with text 'This field must contain an integer number between 1 and 384.' appears.
Tested in:
ovirt-engine-4.4.0-0.0.master.20200317103500.git3e2b0274306.el8.noarch
As far as I could check this behaviour also occurs before this fix so it's not a regression. Quick debug shows that UnitVmModel uses following pattern for validation of hardware config: > setValidTab(TabName.SYSTEM_TAB, isValidTab(TabName.SYSTEM_TAB) && ... && getTotalCPUCores().getIsValid() && ...); Once the system tab is invalid it cannot be valid again. UnitVmModel has some very complex validation rules so it would be best to fix it under separate issue. Note that this seems to be a problem only on this screen (and perhaps other that use the same patter) i.e. 'Network' -> new/edit works correctly. > Find text field that accepts only integers and is not optional ('Edit VM' -> 'System' -> 'Total Virtual CPUs') Unfortunately due to this bugs some integer fields where converted to (or implemented as) string based fields + additional validation in the model. The chosen field is one of them. For "pure" integer field check 'Network' -> new/edit -> MTU -> Custom (or VLAN tagging on the same screen). The difference is that "pure" integer editors provide feedback without submitting the form - it's enough to move the focus to some other field. regarding optional fields(from comment #5): > Note that the bug scenario described in this issue will still apply in case of optional field: editor might be visually in error state but the model will contain null value (which is in this case a valid value). > IMHO this behaviour is OK: we don't want to force user to clean all optional fields before submitting a form. for example check: Virtual Machines -> new/edit -> Random Generator -> Period duration (ms) 1. type some string there (not a number) 2. change focus (field should be marked as invalid and internally the corresponding model will be updated with null) 3. submit the form (should be possible) 4. edit that vm again - there should be no value in field Period duration (default representation of no value state)
> for example check: Virtual Machines -> new/edit -> Random Generator ->
> Period duration (ms)
> 1. type some string there (not a number)
> 2. change focus (field should be marked as invalid and internally the
> corresponding model will be updated with null)
> 3. submit the form (should be possible)
> 4. edit that vm again - there should be no value in field Period duration
> (default representation of no value state)
The only issue with that behaviour is that in case of editing an existing valid value for that field (e.g. edit vm -> "Period duration" is already set to 10 ms) and then type an invalid non integer value then the form is submitted with an empty value instead of the previous one (10 in our exmample)..
> The only issue with that behaviour is that in case of editing an existing valid value for that field (e.g. edit vm -> "Period duration" is already set to 10 ms) and then type an invalid non integer value then the form is submitted with an empty value instead of the previous one (10 in our example). This is a valid point. Only user can resolve such problems: either delete the invalid value if it's not needed or correct it if invalid value is due to typo. Until the problem is resolved the model contains no value for that field ( with 'no value' being mapped to null value). This works well for required fields however for optional fields null is legal value so model level validation was successful. In order to fix this we need to distinguish between null(null value provided) and 'no value' (no value provided). In spirit it is similar to monadic Option container [1]. Note also that the fix also changes the meaning of model's "isValid" attribute - now the value must be present and valid (as before disabled and read-only fields are considered valid). [1] https://www.vavr.io/vavr-docs/#_option Steps:
1) Find text field that accepts only integers and is not optional ('Network' -> new/edit -> MTU -> Custom )
2) Write random number into it (e.g. 1000)
3) Leave the field
4) Come back to the field and edit it to non-integer value (e.g. 'aaa')
5) Submit the changes (Should not pass)
Results:
Correct error message is shown and the changes cannot be submitted.
Steps:
1) Find text field that accepts only integers and is optional ('VMs' -> new/edit -> Random Generator -> Period duration (ms) )
2) Write random number into it (e.g. 1000)
3) Leave the field
4) Come back to the field and edit it to non-integer value (e.g. 'aaa')
5) Submit the changes (Should not pass)
Results:
Correct error message is shown and the changes cannot be submitted.
Verified in:
ovirt-engine-4.4.1-0.1.el8ev.noarch
This bugzilla is included in oVirt 4.4.1 release, published on July 8th 2020. Since the problem described in this bug report should be resolved in oVirt 4.4.1 release, it has been closed with a resolution of CURRENT RELEASE. If the solution does not work for you, please open a new bug report. |