-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
[BUG] Azure Search FieldBuilder does not handle enum conversion exception gracefully #6380
Comments
I'll open a PR with the custom type map dictionary if I can get it to work... |
@mpalumbo7 Thanks for reporting this. It seems like having |
My team sees repro of this issue. |
@brjohnstmsft I tested the custom dictionary and then abandoned it. It worked, but one of my nested classes has the key annotation on it for a different index, which Maybe Anyways, a check for an enum property should still be added with a detailed exception. |
@mpalumbo7 Thanks for poking at this problem. I'm optimistic that |
Running into this problem too, additionally, the same error occurs if you have a field of type
Same error:
Edit: Also for collections, for example |
@Rene-Sackers For the Also, what sort of issues are you having setting up the solution? Maybe I can help. |
@Rene-Sackers I'm adding test coverage for |
Please see the description of this PR for details on where we landed in addressing each of the issues mentioned in this thread: #6833 I'll close this issue once the new version of the SDK is released. There are some other fixes we're working on, so the ETA is at least a few weeks. |
We have a new nuget package released (v 9.1.0) that should contain the fixes from the aforementioned PR: https://www.nuget.org/packages/Microsoft.Azure.Search/ |
Describe the bug
The FieldBuilder class does not support building a
Field
object from a class with an Enum property. The exception is obscure and lost me a lot of timeException or Stack Trace
To Reproduce
Have class with an Enum property, attempt to use
FieldBuilder
on it.Code Snippet
The
FieldBuilder
internally has a dictionary it uses to interpret types into Azure Search supported types.If a property does not match one of these types, it assumes it is a complex type and recursively tries to interpret the property (an Enum) as a complex type. See the
GetDataTypeInfo
method at theelse
condition.Further, if you have a custom
JsonConverter
to translate your nested class into a primitive type (i.e. convert an Address object into a simple string) theFieldBuilder
will incorrectly interpret this property as a complex type - which will not match the serialized JSON (a string) that theSearchIndexClient
will see.Expected behavior
The
FieldBuilder
recognizes an enum, and does not try to interpret it as complex type. It should throw an enum not supported exception or something.Even better, there could be a
TypeAttribute
that FieldBuilder uses in the same way it usesIsSearchable
or other attributes. Or, it could accept a custom dictionary that is used to interpret custom data types to primitive types.Setup (please complete the following information):
Additional context
Add any other context about the problem here.
Information Checklist
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report
The text was updated successfully, but these errors were encountered: