Fixing: Action 4.0.23.0 of Microsoft.SharePoint.Upgrade.SPSiteWssSequence failed.

This was a tough error, THAT IS AN UPGRADE SHOWSTOPPER, that I ran into a few months ago.  Just now getting around to blogging it.  Here's the full error:

[powershell] [SPSiteWssSequence] [ERROR] [9/29/2011 12:02:27 PM]: Action 4.0.23.0 of Microsoft.SharePoint.Upgrade.SPSiteWssSequence failed.
[powershell] [SPSiteWssSequence] [ERROR] [9/29/2011 12:02:27 PM]: Inner Exception: Field name already exists.

The name used for this field is already used by another field in the list.  Select another name and try again.<nativehr>0x81020013</nativehr><nativestack></nativestack>
[powershell] [SPSiteWssSequence] [ERROR] [9/29/2011 12:02:27 PM]:    at Microsoft.SharePoint.Library.SPRequestInternalClass.UpdateField(String bstrUrl, String bstrListName, String bstrXML)
   at Microsoft.SharePoint.Library.SPRequest.UpdateField(String bstrUrl, String bstrListName, String bstrXML)
[powershell] [SPSiteWssSequence] [ERROR] [9/29/2011 12:02:27 PM]: Exception: Field name already exists.

The name used for this field is already used by another field in the list.  Select another name and try again.
[powershell] [SPSiteWssSequence] [ERROR] [9/29/2011 12:02:27 PM]:    at Microsoft.SharePoint.SPGlobal.HandleComException(COMException comEx)
   at Microsoft.SharePoint.Library.SPRequest.UpdateField(String bstrUrl, String bstrListName, String bstrXML)
   at Microsoft.SharePoint.SPField.UpdateCore(Boolean bToggleSealed)
   at Microsoft.SharePoint.SPField.Update()
   at Microsoft.SharePoint.SPFieldIndexCollection.IndexOneField(Object field, Boolean bIndexed)
   at Microsoft.SharePoint.SPFieldIndexCollection.Add(SPField field)
   at Microsoft.SharePoint.Upgrade.RestoreWorkflowAndDatasourceLibraryPermissions.Upgrade()
   at Microsoft.SharePoint.Upgrade.SPActionSequence.Upgrade()

What causes this?  Diving into the upgrade code I find that it is obviously trying to add a column to a list.  But which one?  The hint was in the name of one of the methods – "RestoreWorkflowAndDatasourceLibraryPermissions".  Looking at this, it is checking for all task lists in each site that are setup for workflow.

I reran the code in powershell and eventually found the offending list:

foreach($web in $site.allwebs)

{

$ht = new-object system.collections.hashtable

foreach($list in $web.lists)

{

foreach($ct in $list.ContentTypes)

{

if ($ct.Id.IsCHildof([Microsoft.SHarePoint.SPBuiltInContentTYpeId]::WorkflowTask))

{

$ht.add($list.id, $list.id)

"Web:" + $web.TItle

"List: " + $list.Title

"Content Type:" + $ct.Name

} #end if

} #end ct

} #end list

foreach($id in $ht.values)

{

$l1 = $web.lists[$id]

#$g = new-object system.guid ([Microsoft.SHarePoint.SPBuiltInFieldId]::WorkflowInstanceID.tostring())

$g = new-object system.guid ("de8beacf-5505-47cd-80a6-aa44e7ffe2f4")

#$l1.FieldIndexes.delete($g);

$l1.FieldIndexes.add($list.fields[[Microsoft.SHarePoint.SPBuiltInFieldId]::WorkflowInstanceID]);

$l1.update()

#$g = new-object system.guid([Microsoft.SHarePoint.SPBuiltInFieldId]::Guid.tostring())

$g = new-object system.guid("ae069f25-3ac2-4256-b9c3-15dbc15da0e0")

#$l1.FieldIndexes.delete($g);

$l1.FieldIndexes.add($list.fields[[Microsoft.SHarePoint.SPBuiltInFieldId]::Guid]);

$l1.update() 

} #end hashtable

} #end web

What was the cause?   When you create a workflow, it asks for a task list. 
You can point the workflow at an existing task list or create a new one.  It seems that not only did the users create a workflow that pointed to an existing list, but that list in fact was the task list that the workflow was using for task tracking!!  This causes a loop in the upgrade code and hence the failure.

Fixing it requires deleting some of the fields that were added by the workflow.

Enjoy!

Chris