Improve legacy configuration migration error handling and cleanup (#470)

- Change migration to always clean up legacy keys, even on partial failures
- Upgrade migration messages from Debug to Warn/Info for better visibility
- Add explicit warning when failures occur that manual configuration is needed
- Remove early return on failures to ensure legacy keys are always deleted
- Prevents migration retry loops when some clients fail to configure
main
Marcus Sanatan 2025-12-19 18:30:42 -04:00 committed by GitHub
parent a947c9f9bf
commit 412cc00f41
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 9 additions and 8 deletions

View File

@ -42,18 +42,21 @@ namespace MCPForUnity.Editor.Migrations
var summary = MCPServiceLocator.Client.ConfigureAllDetectedClients();
if (summary.FailureCount > 0 || summary.SuccessCount == 0)
if (summary.FailureCount > 0)
{
if (summary.Messages != null && summary.Messages.Count > 0)
McpLog.Warn($"Legacy configuration migration finished with errors ({summary.GetSummaryMessage()}). details:");
if (summary.Messages != null)
{
McpLog.Debug("Legacy configuration migration details:");
foreach (var message in summary.Messages)
{
McpLog.Debug($" {message}");
McpLog.Warn($" {message}");
}
}
McpLog.Warn($"Legacy configuration migration incomplete ({summary.GetSummaryMessage()}). Will retry next session.");
return;
McpLog.Warn("Legacy keys will be removed to prevent migration loop. Please configure failing clients manually.");
}
else
{
McpLog.Info($"Legacy configuration migration complete ({summary.GetSummaryMessage()})");
}
if (hasServerSrc)
@ -67,8 +70,6 @@ namespace MCPForUnity.Editor.Migrations
EditorPrefs.DeleteKey(UseEmbeddedKey);
McpLog.Info(" ✓ Removed legacy key: MCPForUnity.UseEmbeddedServer");
}
McpLog.Info($"Legacy configuration migration complete ({summary.GetSummaryMessage()})");
}
catch (Exception ex)
{