Assigning Values in XML View Bypasses Validation of Certain Types
URL (minimal example if possible)
https://jsbin.com/cevevaq/edit?js,output
Steps to reproduce the problem
- Open the above page. It contains an XMLView with a
<Button>(just as an example). - See how the value of its
type-property is not a value fromsap.m.ButtonType.
What is the expected result?
The following error should be thrown:
Uncaught Error: "somethingInvalid" is of type string, expected sap.m.ButtonType
What happens instead?
No error thrown. This might lead one thinking that the assigned (enum) value is correctly applied which is not immediately noticeable in some cases.
Any other information? (attach screenshot if possible)
- If a Control is instantiated in JS with wrong (enum) values, the above error is thrown expectedly. I believe this issue applies to other declarative view types as well, not only XML.
- From my observation, only the
widththrows the error expectedly in XML views.
Hi @boghyon, Thanks for sharing your finding. I have created an internal incident 1880543609, [GITHUB] Issue in sap.m.Button - Type validation. The status of the issue will be updated here in GitHub. Regards, Irina
Hi Irina, I just wanted to clarify that this isn't just about sap.m.Button. As far as I could see, this issue applies to all Controls in declarative views. The Button was just as an example.
Hi, Yes, sure, thank you. I ‘ ll add it to the internal message. Best regards, Irina
From: Boghyon Hoffmann [email protected] Reply-To: SAP/openui5 [email protected] Date: Monday, 20. August 2018 at 10:00 To: SAP/openui5 [email protected] Cc: Irina Goetzenberger [email protected], Comment [email protected] Subject: Re: [SAP/openui5] Assigning Values in XML View Bypasses Validation of Certain Types (#2166)
Hi Irina, I just wanted to clarify that this isn't just about sap.m.Button. As far as I could see, this issue applies to all Controls in declarative views. The Button was just as an example.
— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/SAP/openui5/issues/2166#issuecomment-414231004, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AJOclRKfn4JdseQOF4HJu8j-PUdpDNkYks5uSmyvgaJpZM4WAE5V.
It seems that with 1.28, there was an error in this case, but in any newer version it is gone: https://jsbin.com/penaziw/1/edit?html,js,output
It also doesn't seem to be related to sync/async processing or the new create API.
Hi @boghyon,
we looked at this issue and the root cause is a refactoring on the sap/ui/base/DataType implementation (roughly 3 and a half years ago...). The original error @matz3 mentioned is created from the ManagedObject constructor, when a type validation fails. During XML processing, the behavior differs a bit and cannot easily changed.
We will discuss how we can enhance the current behavior in a compatible way. The result will probably an error logging only, as throwing an exception might break existing applications (built in the last couple years).
BR, thodd
The result will probably an error logging only, as throwing an exception might break existing applications
Sounds good. As long as there is some type of notification for the developer that a wrong type was used..
If applicable, I think an additional support rule checking whether the right type was used or not would be also beneficial.
PS: Concerning the support rule: not implemented yet, we will discuss when to tackle this. Right now we only added a better logging for the issue.
@Thodd Sorry, I think the issue is not completely resolved. It works for enum types but for other types such as boolean, no errors are logged.
In https://jsbin.com/cevevaq/edit?html,js,console,output, we can see that only the error log for the Button type is logged whereas there is no error log for the invalid iconFirst value (e.g. "notBoolean").
@boghyon : as discussed, we will have another look at this. I assigned @devtomtom.
Internal incident: DINC0395987