-
Notifications
You must be signed in to change notification settings - Fork 349
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
Issue with data conversion errors. #2906
Comments
Hi @johnwc. This is not an issue that should require a change to the library since it's not a bug in the implementation or a scenario that cuts across users of the library. Our advice is for you to create a custom |
@gathogojr i thought of doing that first, until I noticed there was no way to know what the details of the property is from that method. It only gets passed the raw value and its expected type. How do you suggest I throw an error inside my custom class with the name of the property? Also, a lot of times things are not done because it only effects the library, sometimes things are done to help the developers and end users of the library. This is a perfect example of such that, it helps the end user know what is wrong and where it is. |
@johnwc I understand. We triaged this issue earlier today and came to the same conclusion as you have. A custom payload value converter won't make it possible to report the property that has an invalid value. |
@gathogojr Are you good with the changes I documented above? |
The suggestion looks okay. If you can publish a pull request then we can review. Add tests to verify the changes. |
We are pulling from a third party oData provider that does not adhere to their schema. They are a middleman that takes in data from their clients and turns it into a oData service on the client's behalf. Instead of validating the data against the outgoing schema, they just allow data to flow. If the schema states a property is supposed to be a Edm.Int32, they will allow a value of
2.5
to pass through. Which causes a ODataExceptopn withinConvertFromPayloadValue
Assemblies affected
7.20.0
Reproduce steps
Internal
Expected result
Error to include the name of the property with the invalid data.
Actual result
Generic exception stating
Cannot convert the literal '2.5' to the expected type 'Edm.Int32'.
Additional detail
Will you accept a PR with an update to
ODataPayloadValueConverter
to add a parameter toConvertFromPayloadValue
to pass the name of the property being converted, so that it can be included in the ODataException? I would add an overload for the existing method, so to keep backwards compatibility to anything usingConvertFromPayloadValue
without the property name.The text was updated successfully, but these errors were encountered: