-
Notifications
You must be signed in to change notification settings - Fork 57
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
Link that can reference multiple content types is not being mapped #357
Comments
@georgezubov this seems to work fine for me. In the class you deserialize into, are you using |
@Roblinde no, we don't use
So the object of |
@georgezubov interesting, could you share all your classes and I'll try to figure out what's going on. (Just need the relevant properties) |
@georgezubov do you have a contenttype resolver configured as well? To map your IContentModel interface? |
When I set the classes up like this (some minor changes from your example) I get everything resolved just fine:
|
@Roblinde yes, we have an implementation of IContentTypeResolver which maps specific content types using custom attribute with the content type ID. |
@georgezubov ok, I'll set up a simple content type resolver as well and see if I can reproduce the problem. |
@georgezubov it works fine with a contenttype resolver as well... hmm, is there anything else that could be pertinent? My simple resolver just looked like this:
|
@Roblinde actual serialization error looks like following:
If I change a type of target field to specific type (Level4ContentModel), the instance of the class will be created, but all properties inside of it are null (except SystemProperties, which has Id, LinkType and Type fields populated). |
Aaah, so it's a serialization issue. Is your Level4ContentModel missing from your contenttype resolver by any chance? |
@Roblinde nope, it is being deserialized correctly when it is referenced anywhere else (e.g. in Level1ContentModel). And also everything works as expected in version 7.7.0. |
hmm, that is certainly weird. Version 7.7.0 introduced a faulty way of doing serialization that broke when an item was referenced multiple times so we can't go back to that anyway. It's weird that it's pointing to In your actual live example, is your Level4 entry present anywhere else in the structure or is it exactly as the test.json you provided me? |
@Roblinde You're right, I'm sorry for the misleading, we have rolled back to the 7.6.1, not to the 7.7.0
In the very first response where we spotted the problem, this Level4 was referenced by 2 different entries in the structure, but after that I created separate set of entries and Level4 entry was referenced only once, the result is the same. For both cases, the entry itself is present only in includes. I can try to provide the whole redacted response if that would help. |
If you could that would be great, I'm running out of ideas, but somehow I must be able to reproduce this and find the bug. |
@Roblinde Here is redacted version of the complete response - complete-response.json |
Perfect, thank you... I'll try to reproduce! |
Even with this response I'm not getting any errors. Models look like this:
Any obvious difference from yours? |
Models look correct to me. Also, we don't have any specific serialization settings configured for ContentfulClient, except the TypeNameHandling, not sure if that matters:
|
Hmm if you're overriding the SerializerSettings are you adding these lines as well?
TypeNameHandling.All is also the default for the |
@Roblinde no, we don't have these converters in our configuration. I've just added them to the settings but it doesn't affect the issue, removing override of the settings doesn't seem to change anything either. |
Hmm, this is really strange... If you have the time could you try creating a new console app, adding your classes to that app and try using the SDK from there. Just a clean slate and perhaps we can pinpoint what exactly is causing the issue. |
Hi @georgezubov I've just pushed a beta release to nuget. It includes a complete rework of the reference resolving. I would love for you to test it out and see if it solves your problem. |
Hi @Roblinde I've tried new beta release and we're getting NullReferenceException when trying to load our models: Regrading a new console app to help with reproducing the issue - sure, I will try prepare something soon, just had to switch to the other topics. |
@georgezubov thanks for testing. I will try to find out where this null reference can occur and see what causes it. I'll try to get a new version out shortly. |
@georgezubov a new beta version is now available for you to try out! |
@Roblinde the null reference at BuildObjectGraph is gone, but I'm getting a lot of null reference exceptions here and there after deserialization - some of the fields of the referenced types are null (see example structure), in some cases where we have many references there are some null entries added in the list even though we have only one entry in the list referenced in Contentful
|
Great, thanks for testing. I'll keep working on it. |
Affected version: 8.3.0 and 8.2.1
Issue:
Hello, we have following content type structure:
When we put object of Type2 in the items of Type1, Field of Type3 (which can be the reference to a multiple content types) is always deserialized as null.
Workaround for us is rolling back to version 7.6.1, there everything works as expected.
Here is a redacted version of the API response - test.json
Could you please take a look and help us to resolve this issue? Let me know if any additional information is required. Thanks in advance!
The text was updated successfully, but these errors were encountered: