Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,21 @@ public IdentityMapResult GetUsersInSourceMappedToTarget(TfsProcessor processor)
targetUser = candidates[0];
}
}
targetUser ??= targetUsers.SingleOrDefault(x => x.DisplayName == sourceUser.DisplayName);
try
{
targetUser ??= targetUsers.SingleOrDefault(x => x.DisplayName == sourceUser.DisplayName);
}
catch (InvalidOperationException)
{
Log.LogError("TfsUserMappingTool::GetUsersInSourceMappedToTarget:: Multiple target users found with the same display name '{displayName}'. "
+ "Consider enabling MatchUsersByEmail option to avoid this issue. ",
sourceUser.DisplayName, sourceUser.AccountName);
Comment on lines +199 to +201
Copy link

@coderabbitai coderabbitai bot Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Fix the format string parameter mismatch.

Your log message has one placeholder ({displayName}) but you're passing two parameters (sourceUser.DisplayName, sourceUser.AccountName). The second parameter will be ignored by the logging framework—or worse, cause unexpected behaviour depending on the logger implementation. Either add a {accountName} placeholder to the format string or remove the unused parameter.

🔧 Proposed fix

If you want to include the account name:

-Log.LogError("TfsUserMappingTool::GetUsersInSourceMappedToTarget:: Multiple target users found with the same display name '{displayName}'. "
-    + "Consider enabling MatchUsersByEmail option to avoid this issue. ", 
-    sourceUser.DisplayName, sourceUser.AccountName);
+Log.LogError("TfsUserMappingTool::GetUsersInSourceMappedToTarget:: Multiple target users found with the same display name '{displayName}' for source user '{accountName}'. "
+    + "Consider enabling MatchUsersByEmail option to avoid this issue.", 
+    sourceUser.DisplayName, sourceUser.AccountName);

Or remove the unused parameter:

-Log.LogError("TfsUserMappingTool::GetUsersInSourceMappedToTarget:: Multiple target users found with the same display name '{displayName}'. "
-    + "Consider enabling MatchUsersByEmail option to avoid this issue. ", 
-    sourceUser.DisplayName, sourceUser.AccountName);
+Log.LogError("TfsUserMappingTool::GetUsersInSourceMappedToTarget:: Multiple target users found with the same display name '{displayName}'. "
+    + "Consider enabling MatchUsersByEmail option to avoid this issue.", 
+    sourceUser.DisplayName);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Log.LogError("TfsUserMappingTool::GetUsersInSourceMappedToTarget:: Multiple target users found with the same display name '{displayName}'. "
+ "Consider enabling MatchUsersByEmail option to avoid this issue. ",
sourceUser.DisplayName, sourceUser.AccountName);
Log.LogError("TfsUserMappingTool::GetUsersInSourceMappedToTarget:: Multiple target users found with the same display name '{displayName}' for source user '{accountName}'. "
"Consider enabling MatchUsersByEmail option to avoid this issue.",
sourceUser.DisplayName, sourceUser.AccountName);
Suggested change
Log.LogError("TfsUserMappingTool::GetUsersInSourceMappedToTarget:: Multiple target users found with the same display name '{displayName}'. "
+ "Consider enabling MatchUsersByEmail option to avoid this issue. ",
sourceUser.DisplayName, sourceUser.AccountName);
Log.LogError("TfsUserMappingTool::GetUsersInSourceMappedToTarget:: Multiple target users found with the same display name '{displayName}'. "
"Consider enabling MatchUsersByEmail option to avoid this issue.",
sourceUser.DisplayName);
🤖 Prompt for AI Agents
In @src/MigrationTools.Clients.TfsObjectModel/Tools/TfsUserMappingTool.cs around
lines 199 - 201, The Log.LogError call in
TfsUserMappingTool::GetUsersInSourceMappedToTarget has a format placeholder
mismatch: the message contains only "{displayName}" but passes two values
(sourceUser.DisplayName, sourceUser.AccountName). Fix by aligning format and
parameters—either add a "{accountName}" placeholder to the format string to
include sourceUser.AccountName, or remove the unused sourceUser.AccountName
argument so only sourceUser.DisplayName is passed to Log.LogError.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot, can you add the second placeholder to the message?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

var matchingUsers = targetUsers.Where(x => x.DisplayName == sourceUser.DisplayName).ToList();
Log.LogWarning("TfsUserMappingTool::GetUsersInSourceMappedToTarget:: The list of matching users is {matchingUsers}",
string.Join(", ", matchingUsers.Select(x => $"{x.DisplayName} [{x.MailAddress}]")));
throw;
}

identityMap.Add(new IdentityMapData { Source = sourceUser, Target = targetUser });
}
return new()
Expand Down
Loading