openui5 icon indicating copy to clipboard operation
openui5 copied to clipboard

Assigning Values in XML View Bypasses Validation of Certain Types

Open boghyon opened this issue 7 years ago • 10 comments

URL (minimal example if possible)

https://jsbin.com/cevevaq/edit?js,output

Steps to reproduce the problem

  1. Open the above page. It contains an XMLView with a <Button> (just as an example).
  2. See how the value of its type-property is not a value from sap.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 width throws the error expectedly in XML views.

boghyon avatar Aug 16 '18 15:08 boghyon

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

irinagoetz avatar Aug 17 '18 16:08 irinagoetz

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.

boghyon avatar Aug 20 '18 08:08 boghyon

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.

irinagoetz avatar Aug 20 '18 08:08 irinagoetz

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.

matz3 avatar Aug 24 '18 15:08 matz3

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

Thodd avatar Aug 28 '18 10:08 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.

boghyon avatar Aug 28 '18 11:08 boghyon

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 avatar Sep 06 '18 12:09 Thodd

@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 avatar Sep 17 '18 10:09 boghyon

@boghyon : as discussed, we will have another look at this. I assigned @devtomtom.

Thodd avatar Jan 29 '25 08:01 Thodd

Internal incident: DINC0395987

50gY avatar Jan 29 '25 19:01 50gY