Hi, I have a clean install of Umbraco 8.17.0 with only the contentment package install.
I have a document type with a block editor and a few Contnetment content pickers with umbraco source as the data type and am getting the error below when publishing. Any ideas?
Server error: Contact administrator, see log for full details.
The 'ObjectContent`1' type failed to serialize the response body for content type 'application/json; charset=utf-8'.
The document actually gets published and I see this in the logs:
{"@t":"2021-10-15T20:36:48.3929317Z","@mt":"Document {ContentName} (id={ContentId}) has been published.","ContentName":"test page","ContentId":1084,"SourceContext":"Umbraco.Core.Services.Implement.ContentService","ProcessId":11768,"ProcessName":"w3wp","ThreadId":268,"AppDomainId":2,"AppDomainAppId":"LMW3SVC79ROOT","MachineName":"SOFTSERV18","Log4NetLevel":"INFO ","HttpRequestNumber":11,"HttpRequestId":"df6ce31b-09dd-42df-9b79-4e7562cf2ec2"}
Thanks for raising this, and sorry to hear it's causing you grief.
I haven't seen this particular error myself, but it'd best to clarify the set-up you have.
OK, Umbraco 8.17. I'll assume the latest version of Contentment (v2.2.1 was released last Friday, so I'll assume v2.2.0)?
OK, you have a Block List Editor, with an element type that has Data List fields using the "Umbraco Content by XPath" data-source? Is this 1-level deep? (Just checking that it's not a nested Block List in something else - those types of bugs give me nightmares!)
I'll try to reproduce the error on my local set-up and let you know.
In the meantime, if there is anything else in the logs about this error - e.g. anything that specifically mentions Contentment, if you could share - that'd be great.
Correct on 2.2.0 and yep, just one level deep. The setup is actually very simple, just some contentment pickers on a document type to pick settings and such from content nodes. What's weird is that it throws the errors but the content actually gets picked and save. The error is also generated when I create a node with those pickers.
I've tried with a basic set-up of a Block List editor, with an element type containing a few Data List properties, using the "Umbraco Content by XPath" data-source. One is a dropdown, another a checkbox list, another radio-button list.
They all save without any errors.
I used varying XPath queries too, e.g.
/root/*[@level = 1]/*[@isDoc]
$root/home/articleList/article
On a side note, I wasn't able to get $current, $parent or $site parameter to work inside the Block List editor. I know I had issues with Nested Content, but hadn't tested with Block List editor too. (I end up using Contentment's Content Blocks for my own implementations.) I suspect that's a separate issue to what you are experiencing.
Are you able to share the XPath query that you are using? Of course, feel free to amend the doc type aliases if you need to - basically I'm interested if you are using any of the parameters.
Hmm, any thing in my models builder config i can check for you? I'd also be happy to let you take a peek at the dev site. Again, nothing crazy going on in my setup that would be immediately suspect so stabbing in the dark here as well but happy to put in whatever effort since someone else is experiencing it too.
Any progress with the issue so far? I'm also having this error on Publishing. Umbraco version is 8.16.0, Contentment version is 2.2.0.
I also am using Data List with Data Source = 'Umbraco Content by XPath'. I have several Data Types built on Contentment, they are set up pretty analogical but only few of them are causing the error. I couldn't find any specific relation why this is happening yet (seems like the issue doesn't happen when Contentment's property type is used in Element Type as Nested Content). Anyway, I got an Inner Exception:
System.ObjectDisposedException: Cannot access a disposed object. Object name: 'snapshot'.
at Umbraco.Web.PublishedCache.NuCache.ContentStore.Snapshot.Get(Int32 id) in D:\a\1\s\src\Umbraco.Web\PublishedCache\NuCache\ContentStore.cs:line 1592
at Umbraco.Web.PublishedCache.NuCache.ContentCache.GetById(Boolean preview, Int32 contentId) in D:\a\1\s\src\Umbraco.Web\PublishedCache\NuCache\ContentCache.cs:line 226
at Umbraco.Web.PublishedCache.NuCache.Navigable.Source.Get(Int32 id) in D:\a\1\s\src\Umbraco.Web\PublishedCache\NuCache\Navigable\Source.cs:line 25
at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
at Umbraco.Core.Xml.XPath.NavigableNavigator.MoveToFirstChildElement() in D:\a\1\s\src\Umbraco.Core\Xml\XPath\NavigableNavigator.cs:line 586
at Umbraco.Core.Xml.XPath.NavigableNavigator.MoveToFirstChild() in D:\a\1\s\src\Umbraco.Core\Xml\XPath\NavigableNavigator.cs:line 559
at MS.Internal.Xml.XPath.XPathChildIterator.MoveNext()
at MS.Internal.Xml.XPath.ChildrenQuery.Advance()
at MS.Internal.Xml.XPath.ChildrenQuery.Advance()
at MS.Internal.Xml.XPath.ChildrenQuery.Advance()
at MS.Internal.Xml.XPath.ChildrenQuery.Advance()
at MS.Internal.Xml.XPath.FilterQuery.Advance()
at MS.Internal.Xml.XPath.ChildrenQuery.Advance()
at MS.Internal.Xml.XPath.FilterQuery.Advance()
at MS.Internal.Xml.XPath.XPathSelectionIterator.MoveNext()
at Umbraco.Web.PublishedCache.NuCache.ContentCache.<GetByXPath>d__31.MoveNext() in D:\a\1\s\src\Umbraco.Web\PublishedCache\NuCache\ContentCache.cs:line 359
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeList(JsonWriter writer, IEnumerable values, JsonArrayContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty) in /_/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalWriter.cs:line 677
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeDictionary(JsonWriter writer, IDictionary values, JsonDictionaryContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty) in /_/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalWriter.cs:line 1089
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty) in /_/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalWriter.cs:line 469
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeList(JsonWriter writer, IEnumerable values, JsonArrayContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty) in /_/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalWriter.cs:line 703
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty) in /_/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalWriter.cs:line 469
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeList(JsonWriter writer, IEnumerable values, JsonArrayContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty) in /_/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalWriter.cs:line 703
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty) in /_/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalWriter.cs:line 469
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeList(JsonWriter writer, IEnumerable values, JsonArrayContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty) in /_/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalWriter.cs:line 703
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty) in /_/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalWriter.cs:line 469
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType) in /_/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalWriter.cs:line 95
at Newtonsoft.Json.JsonSerializer.SerializeInternal(JsonWriter jsonWriter, Object value, Type objectType) in /_/Src/Newtonsoft.Json/JsonSerializer.cs:line 1151
at System.Net.Http.Formatting.BaseJsonMediaTypeFormatter.WriteToStream(Type type, Object value, Stream writeStream, Encoding effectiveEncoding)
at System.Net.Http.Formatting.JsonMediaTypeFormatter.WriteToStream(Type type, Object value, Stream writeStream, Encoding effectiveEncoding)
at System.Net.Http.Formatting.BaseJsonMediaTypeFormatter.WriteToStreamAsync(Type type, Object value, Stream writeStream, HttpContent content, TransportContext transportContext, CancellationToken cancellationToken)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Umbraco.Web.WebApi.AngularJsonMediaTypeFormatter.<WriteToStreamAsync>d__1.MoveNext() in D:\a\1\s\src\Umbraco.Web\WebApi\AngularJsonMediaTypeFormatter.cs:line 52
Unfortunately I haven't been able to reproduce this issue at all.
The frustrating part (for me) is that the exception messages have no mention of Contentment, so there isn't any concrete that pins this on the "Umbraco Content by XPath" data-source. (I'm not saying that it isn't, just that I'm unable to verify that).
Wondering if there is anything else noteworthy going on with the doctypes? e.g. other property types, packages used yet? mostly so I can try to reproduce the error as best I can.
OK, I've managed to reproduce the error. I'm not entirely sure why it didn't happen previously, nor why this error hadn't appeared when I first developed the XPath data-source, very strange. Anyway, it's good that I can reproduce it... next to figure out a resolution. 🤞
Update. (brain dump / dev notes)
From looking over Umbraco release changes, I suspect this issue arose since v8.16.0 - I noticed the introduction of several IDisposable interfaces for various services.
...which is then lazily executed later on, (I presume from the AngularJsonMediaTypeFormatter code) - by that time the Content Cache (snapshot) has probably been disposed, hence the Cannot access a disposed object. Object name: 'snapshot'. error.
My resolution would be to call .ToList() on the XPath data-source, whilst the Content Cache snapshot is still available.
I'll post back on here once I can confirm... and figure out a patch release - as Contentment is now on v3.x, so wondering how much effort it is (for me personally) to do a v2.2.2 patch release. 🤔
Hi Lee! Thanks for the fast response and for sharing details regarding the issue. I appreciate all that you've done. Will keep an eye on further updates from you.
Error when publishing document
Hi, I have a clean install of Umbraco 8.17.0 with only the contentment package install.
I have a document type with a block editor and a few Contnetment content pickers with umbraco source as the data type and am getting the error below when publishing. Any ideas?
Server error: Contact administrator, see log for full details. The 'ObjectContent`1' type failed to serialize the response body for content type 'application/json; charset=utf-8'.
The document actually gets published and I see this in the logs: {"@t":"2021-10-15T20:36:48.3929317Z","@mt":"Document {ContentName} (id={ContentId}) has been published.","ContentName":"test page","ContentId":1084,"SourceContext":"Umbraco.Core.Services.Implement.ContentService","ProcessId":11768,"ProcessName":"w3wp","ThreadId":268,"AppDomainId":2,"AppDomainAppId":"LMW3SVC79ROOT","MachineName":"SOFTSERV18","Log4NetLevel":"INFO ","HttpRequestNumber":11,"HttpRequestId":"df6ce31b-09dd-42df-9b79-4e7562cf2ec2"}
Update, I do get this in the console and note that nodes without Contentment don't generate an error:
umbraco/backoffice/UmbracoApi/Content/PostSave:1
This also only seems to be happening when the data source is Umbraco content by xpath.
Hi Amir,
Thanks for raising this, and sorry to hear it's causing you grief.
I haven't seen this particular error myself, but it'd best to clarify the set-up you have.
OK, Umbraco 8.17. I'll assume the latest version of Contentment (v2.2.1 was released last Friday, so I'll assume v2.2.0)?
OK, you have a Block List Editor, with an element type that has Data List fields using the "Umbraco Content by XPath" data-source? Is this 1-level deep? (Just checking that it's not a nested Block List in something else - those types of bugs give me nightmares!)
I'll try to reproduce the error on my local set-up and let you know.
In the meantime, if there is anything else in the logs about this error - e.g. anything that specifically mentions Contentment, if you could share - that'd be great.
Thanks,
- Lee
Correct on 2.2.0 and yep, just one level deep. The setup is actually very simple, just some contentment pickers on a document type to pick settings and such from content nodes. What's weird is that it throws the errors but the content actually gets picked and save. The error is also generated when I create a node with those pickers.
Hi Amir,
I've tried with a basic set-up of a Block List editor, with an element type containing a few Data List properties, using the "Umbraco Content by XPath" data-source. One is a dropdown, another a checkbox list, another radio-button list.
They all save without any errors.
I used varying XPath queries too, e.g.
/root/*[@level = 1]/*[@isDoc]
$root/home/articleList/article
On a side note, I wasn't able to get
$current
,$parent
or$site
parameter to work inside the Block List editor. I know I had issues with Nested Content, but hadn't tested with Block List editor too. (I end up using Contentment's Content Blocks for my own implementations.) I suspect that's a separate issue to what you are experiencing.Are you able to share the XPath query that you are using? Of course, feel free to amend the doc type aliases if you need to - basically I'm interested if you are using any of the parameters.
Thanks,
- Lee
It was this //documentTypeAlias
I was just trying to get all of the document types with any given alias, tried with 3 different document types.
Hi Amir, thanks.
I've tried the
//article
XPath query now too. Unfortunately, I'm still not able to reproduce the error.I'm not sure what next to suggest.
Hmm, any thing in my models builder config i can check for you? I'd also be happy to let you take a peek at the dev site. Again, nothing crazy going on in my setup that would be immediately suspect so stabbing in the dark here as well but happy to put in whatever effort since someone else is experiencing it too.
Thanks Amir. Let's see if @brewmaxwell649 comes back with any further details.
Thinking about it, I doubt it'd be ModelsBuilder related - I don't think that comes into play when saving/publishing content nodes.
Turns out the user brewmaxwell649 was a spam profile unfortunately - So don't expect any further details from this person :-)
/Jan
Thanks Jan! I had a niggle feeling it was a spam account, but took it at face value.
Any progress with the issue so far? I'm also having this error on Publishing. Umbraco version is 8.16.0, Contentment version is 2.2.0.
I also am using Data List with Data Source = 'Umbraco Content by XPath'. I have several Data Types built on Contentment, they are set up pretty analogical but only few of them are causing the error. I couldn't find any specific relation why this is happening yet (seems like the issue doesn't happen when Contentment's property type is used in Element Type as Nested Content). Anyway, I got an Inner Exception:
I'd appreciate any help :)
Hi Viktoriia, thanks for the extra info.
Unfortunately I haven't been able to reproduce this issue at all.
The frustrating part (for me) is that the exception messages have no mention of Contentment, so there isn't any concrete that pins this on the "Umbraco Content by XPath" data-source. (I'm not saying that it isn't, just that I'm unable to verify that).
Wondering if there is anything else noteworthy going on with the doctypes? e.g. other property types, packages used yet? mostly so I can try to reproduce the error as best I can.
Thanks,
- Lee
OK, I've managed to reproduce the error. I'm not entirely sure why it didn't happen previously, nor why this error hadn't appeared when I first developed the XPath data-source, very strange. Anyway, it's good that I can reproduce it... next to figure out a resolution. 🤞
Update. (brain dump / dev notes)
From looking over Umbraco release changes, I suspect this issue arose since v8.16.0 - I noticed the introduction of several
IDisposable
interfaces for various services.https://github.com/umbraco/Umbraco-CMS/compare/release-8.15.3...release-8.16.0
Meaning that when the Umbraco Content Cache's
GetByXPath
is called, a LINQ result is returned...https://github.com/leekelleher/umbraco-contentment/blob/2.2.1/src/Umbraco.Community.Contentment/DataEditors/DataList/DataSources/UmbracoContentXPathDataListSource.cs#L101-L109
...which is then lazily executed later on, (I presume from the
AngularJsonMediaTypeFormatter
code) - by that time the Content Cache (snapshot) has probably been disposed, hence theCannot access a disposed object. Object name: 'snapshot'.
error.My resolution would be to call
.ToList()
on the XPath data-source, whilst the Content Cache snapshot is still available.I'll post back on here once I can confirm... and figure out a patch release - as Contentment is now on v3.x, so wondering how much effort it is (for me personally) to do a v2.2.2 patch release. 🤔
Hi Lee! Thanks for the fast response and for sharing details regarding the issue. I appreciate all that you've done. Will keep an eye on further updates from you.
Good news. I was able to fix this bug and have just released Contentment v2.2.2! 🎉
Yay! Just upgraded - everything works fine! Thank you Lee!! :)
is working on a reply...