Skip to content

Commit ee09b02

Browse files
authored
Fix for Index Issue (#2617)
🐛 (TfsTestPlansAndSuitesMigrationProcessor.cs): fix potential index out of range error by using FirstOrDefault The change from accessing the first element of the testPlans list directly to using FirstOrDefault prevents a potential IndexOutOfRangeException. This ensures that if the list is empty, the testPlan variable will be set to null instead of causing an error, improving the robustness of the code.
2 parents c4f3801 + 5fb12e8 commit ee09b02

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ private ITestPlan FindTestPlan(string planName, int sourcePlanId)
615615
Log.LogWarning("We found multiple test Plans with the name '{TestPlanName}'. They have ID(s) of '{result}'! We only have name at this point as a unique identifier and duplicates will break the code. Ensure that all Test Plans have unique names.", planName, result);
616616
throw new Exception(string.Format("Test plans {0} all have the same name!", result));
617617
}
618-
testPlan = testPlans[0];
618+
testPlan = testPlans.FirstOrDefault();
619619

620620
if (testPlan != null)
621621
{

0 commit comments

Comments
 (0)