Skip to content
This repository has been archived by the owner on Dec 13, 2021. It is now read-only.

Casting IPublishedContent to specific Model using Ditto mixing up property values between nodes on the same level #249

Closed
mjolicseven opened this issue Dec 11, 2021 · 3 comments

Comments

@mjolicseven
Copy link

mjolicseven commented Dec 11, 2021

Cross-linking with original issue raised on Umbraco CMS.

Let me give a brief introduction on how our content is structured in the Umbraco CMS: We have an Episode node, that's parent node. Beneath that node we have a VideoAsset node (defined as UmbracoProperty), which is child node. We tracked the root cause of this issue and found out that the call to method .As<T> (part of the Ditto assembly) returned back a wrong child video asset. However, everything looks okay in the database.

This is the use-case when issue happens:
We have an endpoint which is getting Episode (IPublishedContent) by Id from the CMS and sending SNS message to our other services. In small period of time we're sending over a 1k requests to this endpoint, picking up content, casting it with Ditto and sending SNS message further.

This process is separated from publishing content item in the CMS.
Issue can not be reproduced when we're publishing single episode.

@leekelleher
Copy link
Collaborator

@mjolicseven Thanks for raising this.

To be upfront and realistic about expectations, I haven't worked on Ditto in the past 3 years, so my knowledge of its inner workings is now quite hazy. I wouldn't expect a bug-fix/patch-release to come from me for this issue, (my free/open-source priorities are elsewhere these days).

My initial thought is that you've found a concurrency bug (in Ditto). With the 1,000 requests hitting the API endpoint in quick succession, I suspect that something in Ditto's internal caching is wrong value/property.

Is your API service something that is actively being developed? and are you the developer?

With 3 years hindsight, my recommendation would be to remove the Ditto .As<T>() call and manually map the IPublishedContent objects to the view-models. That way, you reduce the amount of Reflection/processing required to construct and populate the view-models.

Personally, for Umbraco v8/v9, I've been using the built-in ModelsBuilder objects as my view-models.

I'm not sure how much this helps you. I'm happy to keep this open, but I'm not actively continuing development of Ditto.

On a side-note, if anyone else reading this would like to fork Ditto and continue the maintenance, I'm happy to hand over the repository. 👍

@mjolicseven
Copy link
Author

Hey @leekelleher,

Thanks for your honest answer. Since our API is actively being developed I have already started with manual mapping of IPublishedContent to the models. This would definitely solve our problems - we just wanted to find a shortcut if possible :)

If you want you can now close the issue.

@leekelleher
Copy link
Collaborator

Thanks @mjolicseven.

I hope Ditto hasn't caused too many headaches! 😬 All the best with your API. 🚀

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants