U4-1976 - Bug when creating content item

Created by Chris Gaskell 21 Mar 2013, 15:20:22 Updated by Morten Christensen 22 Mar 2013, 10:59:26

When I try to create a content item I'm getting the following error. I'm using Umbraco v6.0.1 (Assembly version: 1.0.4807.33318)

Server Error in '/' Application.

'' is an invalid expanded name.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentException: '' is an invalid expanded name.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[ArgumentException: '' is an invalid expanded name.] System.Xml.Linq.XName.Get(String expandedName) +198375 Umbraco.Core.Models.ContentExtensions.ToXml(IContentBase contentBase, String nodeName) +109 Umbraco.Core.Models.ContentExtensions.ToXml(IContent content) +198 Umbraco.Core.Services.ContentService.Save(IContent content, Boolean changeState, Int32 userId, Boolean raiseEvents) +413 Umbraco.Core.Services.ContentService.Save(IContent content, Int32 userId, Boolean raiseEvents) +20 umbraco.cms.businesslogic.web.Document.MakeNew(String Name, DocumentType dct, User u, Int32 ParentId) +266 umbraco.contentTasks.Save() +76 umbraco.presentation.create.dialogHandler_temp.Create(String NodeType, Int32 TypeId, Int32 NodeId, String Text) +753 umbraco.cms.presentation.create.controls.content.doCreation() +223 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +155 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3804

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18033


Chris Gaskell 21 Mar 2013, 15:23:03

Just to add - this was when I had a doctype with no inheritance called '404'. I've re-created the doctype and named it 'Page Not Found' and all works fine.

Morten Christensen 21 Mar 2013, 20:41:37

I think that might be the problem. The name of the doc type is used as an XML element when generating the xml cache and as far as I remember numbers aren't valid element names.

Chris McKee 21 Mar 2013, 20:44:51

XML Element Names

  • Names can contain letters, numbers, and other characters
  • Names cannot start with a number or punctuation character
  • Names cannot start with the letters xml (or XML, or Xml, etc)
  • Names cannot contain spaces

Probably worth adding that test in.

Morten Christensen 21 Mar 2013, 20:55:47

Yup, we need to add that as part of the test for valid DocType aliases. Of the bullets above I think we only got spaces covered as well as some invalid characters, but not numbers.

Morten Christensen 22 Mar 2013, 09:34:22

Looking into this we do actually have checks according to the list that Chris wrote above, but the problem is that it strips the numbers from the Alias, so if you name it 404 it'll actually remove all numbers and end up with an empty alias, which is what caused the exception above. Question is if we should just prefix the Alias with a letter to make the Alias valid. You can always change it to something else. Alternatively we can throw an error indicating that the Alias is empty.

Morten Christensen 22 Mar 2013, 10:59:15

After having talked it over with some of the other guys I have added a validation check to the create dialog for doc types and a check in the ContentTypeRepository, which ensures that doc types cannot be saved if they have an empty alias (the removal of invalid characters is done prior to saving / hitting the repository).

Priority: Normal

Type: Bug

State: Fixed

Assignee: Morten Christensen

Difficulty: Normal


Backwards Compatible: True

Fix Submitted:

Affected versions: 6.0.2

Due in version: 6.0.3


Story Points: