Skip to content

Commit e9ea86d

Browse files
authored
Bug fix for lame FieldDefinitionNotExistException (#2626)
🐛 (TfsWorkItemMigrationProcessor.cs): handle FieldDefinitionNotExistException when setting ClosedDate field Wraps the assignment of the "ClosedDate" field in a try-catch block to handle the FieldDefinitionNotExistException. This change prevents the application from crashing when the field definition does not exist, which can occur due to inconsistencies in the TFS API. The exception is caught and ignored to ensure the migration process continues smoothly. Co-Authored: @anderssonpof
2 parents ee09b02 + 1657144 commit e9ea86d

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/MigrationTools.Clients.TfsObjectModel/Processors/TfsWorkItemMigrationProcessor.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,9 +422,16 @@ private void PopulateWorkItem(WorkItemData oldWorkItemData, WorkItemData newWork
422422
newWorkItem.Fields["Microsoft.VSTS.Common.ClosedDate"].Value = oldWorkItem.Fields["Microsoft.VSTS.Common.ClosedDate"].Value;
423423
}
424424
newWorkItem.State = oldWorkItem.State;
425-
if (newWorkItem.Fields.Contains("Microsoft.VSTS.Common.ClosedDate") && newWorkItem.Fields["Microsoft.VSTS.Common.ClosedDate"].IsEditable)
425+
try
426426
{
427-
newWorkItem.Fields["Microsoft.VSTS.Common.ClosedDate"].Value = oldWorkItem.Fields["Microsoft.VSTS.Common.ClosedDate"].Value;
427+
if (newWorkItem.Fields.Contains("Microsoft.VSTS.Common.ClosedDate") && newWorkItem.Fields["Microsoft.VSTS.Common.ClosedDate"].IsEditable)
428+
{
429+
newWorkItem.Fields["Microsoft.VSTS.Common.ClosedDate"].Value = oldWorkItem.Fields["Microsoft.VSTS.Common.ClosedDate"].Value;
430+
}
431+
}
432+
catch (FieldDefinitionNotExistException ex)
433+
{
434+
// Eat exception coz the TFS API Sucks
428435
}
429436
newWorkItem.Reason = oldWorkItem.Reason;
430437

0 commit comments

Comments
 (0)