Skip to content

Commit 1d176c4

Browse files
committed
šŸ› (TfsWorkItemMigrationProcessor.cs): add check for field existence before accessing 'ClosedDate'
The code now checks if the "Microsoft.VSTS.Common.ClosedDate" field exists before attempting to access it. This prevents potential runtime errors when the field is not present in the work item, ensuring more robust and error-free execution.
1 parent 2e7fa8d commit 1d176c4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

ā€Žsrc/MigrationTools.Clients.TfsObjectModel/Processors/TfsWorkItemMigrationProcessor.csā€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,12 +419,12 @@ private void PopulateWorkItem(WorkItemData oldWorkItemData, WorkItemData newWork
419419
}
420420

421421
newWorkItem.Title = oldWorkItem.Title;
422-
if (newWorkItem.Fields["Microsoft.VSTS.Common.ClosedDate"].IsEditable)
422+
if (newWorkItem.Fields.Contains("Microsoft.VSTS.Common.ClosedDate") && newWorkItem.Fields["Microsoft.VSTS.Common.ClosedDate"].IsEditable)
423423
{
424424
newWorkItem.Fields["Microsoft.VSTS.Common.ClosedDate"].Value = oldWorkItem.Fields["Microsoft.VSTS.Common.ClosedDate"].Value;
425425
}
426426
newWorkItem.State = oldWorkItem.State;
427-
if (newWorkItem.Fields["Microsoft.VSTS.Common.ClosedDate"].IsEditable)
427+
if (newWorkItem.Fields.Contains("Microsoft.VSTS.Common.ClosedDate") && newWorkItem.Fields["Microsoft.VSTS.Common.ClosedDate"].IsEditable)
428428
{
429429
newWorkItem.Fields["Microsoft.VSTS.Common.ClosedDate"].Value = oldWorkItem.Fields["Microsoft.VSTS.Common.ClosedDate"].Value;
430430
}

0 commit comments

Comments
Ā (0)