I'm experiencing some odd behvaiour with a doctype that has a nestedcontent property.
Whenever i try to access the property it throws an Argumentexception with the message "Empty guid."
The property has a few values set ind the backoffice:
I'm using modelsbuilder and is accessing the property through the generated models:
...
var contentPage = Umbraco.Content(id.Value);
if (contentPage == null || !(contentPage is DefaultPage))
return (BadRequest("Unexpected nodetype"));
var homepage = (DefaultPage)contentPage;
if(homepage.DefaultValues != null)
{
foreach(var kvp in homepage.DefaultValues)
{
BackendRequest.Add(kvp.Key, kvp.Value);
}
}
I can't find any similar issues on this or other tech forums.
Worth noting that this is happening in an API controller extending UmbracoApiController.
For anyone else coming across this post - we had a similar issue and it worked out to be when pasting nested content from another nested content block.
To resolve this, we have to past the content, then expand every nested content block to show the data that was pasted in. If we hit save and publish then it all works properly.
Kristian and this comment helped me solve my issues. I originally used "key" as a property name but even after renaming I still got the "empty guid" error. Deleting the content node finally fixed everything.
We are also getting this; fortunately it's in a development environment where I'm testing, but the solutions above won't work for us as it's an automatic process that loads around 400 documents from XML.
The process sets accordion data into Nested Content like this:
This used to automatically set the key value in the UmbracoPropertyData table, but now it seems that it sets a blank Guid instead - this then can't be parsed or loaded on the front end.
I'm going to try manually inserting the key but this seems like a pretty serious bug - I will raise it with support!
Just a though : You could try something like copy & paste, but in code, during the process above ?
// import stuff and save doc. New doc is 1592
var documentToCopy = contentService.GetById(1592);
var newDoc = contentService.Copy(documentToCopy, 1558, false, 0);
// pushish newDoc
// delete oldDoc
It appears I can "fix" it by just adding the key to the object myself - I might need to revisit this if they fix the bug! (Also I'm making the dangerous assumption here that the Guid I generate isn't going to be used elsewhere, although I think that's fairly safe).
Unfortunately this is only one update and there are lots, so deleting/adding new documents would generate a massive overhead - it would only be on the back office server, but it would play havoc with the process I think.
Have you tried the steps above i mentioned ? Try creating a copy of the page and seeing if the copy still throws the error.
Just make sure when you create the copy you unselect the "relate to original" option
We've got the same problem with copied items in nested content on an umbraco 8.7.0 installation. Does anyone know if this problem is fixed in the newer versions?
Thanks a lot.
Ive not tried this in U10 (which we have just started using), but for U8, i wrote this class as a workaround that fixed the issue (Note: You will need to replace "pageModules" with the alias of the nested content field) :
/// <summary>
/// Seems to be a bug with copy and pasting of nested content items in Umbraco 8.5 -> 8.10.2
/// It maybe when you copy and paste an item from a nested content tree to another nc tree,
/// that has a nested content prop in it with its own contents.
/// It seems to set some guids to Guid.Empty, and this blows up the front end.
///
/// This code is to get around that by checking the page modules every time we save.
/// Its not pretty, but it saves me pulling out my hair.
/// </summary>
public class Umbraco_CopyPasteBug_Fix_Composer : ComponentComposer<Umbraco_CopyPasteBug_Fix_Component>
{ }
public class Umbraco_CopyPasteBug_Fix_Component : IComponent
{
public void Initialize()
{
ContentService.Saving += this.ContentService_Saving;
}
private void ContentService_Saving(Umbraco.Core.Services.IContentService sender, Umbraco.Core.Events.ContentSavingEventArgs e)
{
foreach (var entity in e.SavedEntities)
{
foreach (var prop in entity.Properties)
{
if (prop.Alias == "pageModules")
{
var val = prop.Values.FirstOrDefault();
if (val?.EditedValue is string)
{
string edit = val.EditedValue as string;
while (edit.Contains("00000000-0000-0000-0000-000000000000"))
{
edit = edit.ReplaceFirst("00000000-0000-0000-0000-000000000000", Guid.NewGuid().ToString());
}
prop.SetValue(edit);
}
}
}
}
}
public void Terminate()
{
ContentService.Saving -= ContentService_Saving;
}
}
Base on Carlos Rey's wonderful answer, here is the v10 implementation:
public class NestedContentEmptyGuidFixComposer : IComposer
{
public void Compose(IUmbracoBuilder builder)
{
builder.AddNotificationHandler<ContentSavingNotification, NestedContentEmptyGuidFixHandler>();
}
}
and
public class NestedContentEmptyGuidFixHandler : INotificationHandler<ContentSavingNotification>
{
public void Handle(ContentSavingNotification notification)
{
string emptyGuidString = Guid.Empty.ToString();
foreach (var entity in notification.SavedEntities)
{
foreach (var prop in entity.Properties)
{
if (prop.Alias != "pageComponents")
continue;
var val = prop.Values.FirstOrDefault();
if (val?.EditedValue is not string edit)
continue;
while (edit.Contains(emptyGuidString))
{
edit = edit.ReplaceFirst(emptyGuidString, Guid.NewGuid().ToString());
}
prop.SetValue(edit);
}
}
}
}
Nested Content throws Empty guid. argument exception
I'm experiencing some odd behvaiour with a doctype that has a nestedcontent property. Whenever i try to access the property it throws an Argumentexception with the message "Empty guid."
The property has a few values set ind the backoffice:
I'm using modelsbuilder and is accessing the property through the generated models:
I can't find any similar issues on this or other tech forums.
Worth noting that this is happening in an API controller extending UmbracoApiController.
Figured it out now. It was because i named a property "key" on the element type used in the nested content.
This overrides the existing key property which contains a guid.
I renamed the properties, and it works.
For anyone else coming across this post - we had a similar issue and it worked out to be when pasting nested content from another nested content block.
To resolve this, we have to past the content, then expand every nested content block to show the data that was pasted in. If we hit save and publish then it all works properly.
For anyone running into this, it looks like a bug in Umbraco when using the copy and paste funtion for content in a nested list.
I found the easiest way to fix this is to:
The act of creating a copy of that page seems to fix the guids in the nested list. The new copy of the page works fine.
Kristian and this comment helped me solve my issues. I originally used "key" as a property name but even after renaming I still got the "empty guid" error. Deleting the content node finally fixed everything.
We are also getting this; fortunately it's in a development environment where I'm testing, but the solutions above won't work for us as it's an automatic process that loads around 400 documents from XML.
The process sets accordion data into Nested Content like this:
This used to automatically set the key value in the UmbracoPropertyData table, but now it seems that it sets a blank Guid instead - this then can't be parsed or loaded on the front end.
I'm going to try manually inserting the key but this seems like a pretty serious bug - I will raise it with support!
Just a though : You could try something like copy & paste, but in code, during the process above ?
Hacky, but might get you back up and running
It appears I can "fix" it by just adding the key to the object myself - I might need to revisit this if they fix the bug! (Also I'm making the dangerous assumption here that the Guid I generate isn't going to be used elsewhere, although I think that's fairly safe).
Unfortunately this is only one update and there are lots, so deleting/adding new documents would generate a massive overhead - it would only be on the back office server, but it would play havoc with the process I think.
Thanks for the thought though! :)
Getting the same error in 8.11.1..
Have some nested content inside a nested content that trows a "Empty guid" after I copied.
When I open a Nested content. It opens all..
If I copy and then delete each nested content and then insert it again then they works... ?
Tried to open all nested and save.. Didn't do anything..
Have you tried the steps above i mentioned ? Try creating a copy of the page and seeing if the copy still throws the error. Just make sure when you create the copy you unselect the "relate to original" option
It's on the root node, it´s a lot of sub pages that needs to be copied.. :p
I will give it a try
We've got the same problem with copied items in nested content on an umbraco 8.7.0 installation. Does anyone know if this problem is fixed in the newer versions? Thanks a lot.
Ive not tried this in U10 (which we have just started using), but for U8, i wrote this class as a workaround that fixed the issue (Note: You will need to replace "pageModules" with the alias of the nested content field) :
Base on Carlos Rey's wonderful answer, here is the v10 implementation:
and
I can confirm this is still happening in v11.4.0. Thanks for you're helpful workaround/s!
is working on a reply...