Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assigning Values in XML View Bypasses Validation of Certain Types #2166

Open
boghyon opened this issue Aug 16, 2018 · 10 comments
Open

Assigning Values in XML View Bypasses Validation of Certain Types #2166

boghyon opened this issue Aug 16, 2018 · 10 comments
Assignees

Comments

@boghyon
Copy link
Contributor

boghyon commented Aug 16, 2018

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.
@irinagoetz
Copy link
Contributor

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

@boghyon
Copy link
Contributor Author

boghyon commented Aug 20, 2018

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.

@irinagoetz
Copy link
Contributor

irinagoetz commented Aug 20, 2018 via email

@matz3
Copy link
Member

matz3 commented Aug 24, 2018

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.

@Thodd
Copy link
Contributor

Thodd commented Aug 28, 2018

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

@boghyon
Copy link
Contributor Author

boghyon commented Aug 28, 2018

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.

@Thodd
Copy link
Contributor

Thodd commented Sep 6, 2018

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.

@boghyon
Copy link
Contributor Author

boghyon commented Sep 17, 2018

@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").

@Thodd
Copy link
Contributor

Thodd commented Jan 29, 2025

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

@i556484
Copy link
Member

i556484 commented Jan 29, 2025

Internal incident: DINC0395987

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants