Skip to content

Conversation

@msanatan
Copy link
Contributor

@msanatan msanatan commented Dec 19, 2025

  • 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

Partly addresses #464.

Summary by Sourcery

Improve handling of legacy configuration migration outcomes while ensuring legacy keys are always cleaned up.

Enhancements:

  • Always log legacy migration failures and details at warning level for better visibility.
  • Log a clear informational message when legacy migration completes successfully.
  • Add an explicit warning that legacy keys will still be removed after migration errors and that failing clients require manual configuration.
  • Ensure legacy configuration keys are removed even when some client configurations fail, avoiding repeated migration attempts.

- 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
@msanatan msanatan self-assigned this Dec 19, 2025
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Dec 19, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adjusts the legacy server configuration migration to always remove legacy keys, improves logging visibility and messaging on partial failures, and avoids retry loops when some clients fail to configure.

Sequence diagram for updated legacy configuration migration behavior

sequenceDiagram
    actor UnityEditor
    participant LegacyServerSrcMigration
    participant MCPServiceLocator
    participant Client
    participant EditorPrefs
    participant McpLog

    UnityEditor->>LegacyServerSrcMigration: RunMigrationIfNeeded()
    LegacyServerSrcMigration->>MCPServiceLocator: Client.ConfigureAllDetectedClients()
    MCPServiceLocator-->>LegacyServerSrcMigration: summary

    alt summary.FailureCount > 0
        LegacyServerSrcMigration->>McpLog: Warn([Legacy configuration migration finished with errors (...). details:])
        alt summary.Messages != null
            loop for each message in summary.Messages
                LegacyServerSrcMigration->>McpLog: Warn([  {message}])
            end
        end
        LegacyServerSrcMigration->>McpLog: Warn([Legacy keys will be removed to prevent migration loop. Please configure failing clients manually.])
    else summary.FailureCount == 0
        LegacyServerSrcMigration->>McpLog: Info([Legacy configuration migration complete (...)])
    end

    alt hasServerSrc
        LegacyServerSrcMigration->>EditorPrefs: DeleteKey(ServerSrcKey)
        LegacyServerSrcMigration->>McpLog: Info([  ✓ Removed legacy key: MCPForUnity.ServerSrc])
    end

    alt UseEmbedded
        LegacyServerSrcMigration->>EditorPrefs: DeleteKey(UseEmbeddedKey)
        LegacyServerSrcMigration->>McpLog: Info([  ✓ Removed legacy key: MCPForUnity.UseEmbeddedServer])
    end

    LegacyServerSrcMigration-->>UnityEditor: migration completed (no retry loop)
Loading

File-Level Changes

Change Details Files
Change migration completion/abort logic so legacy keys are cleaned up even when some client configurations fail, and logging clearly distinguishes success vs partial failure.
  • Treat any non-zero FailureCount as an error condition, independent of SuccessCount being zero.
  • On failures, log a high-level warning with the summary message and per-message details at Warn level instead of Debug.
  • Remove the early return on failures so that legacy editor preference keys are always deleted after migration attempts.
  • On success (no failures), log an Info-level completion message using the summary message.
  • Remove the duplicated completion Info log from the end of the migration since success is now logged in the conditional block.
MCPForUnity/Editor/Migrations/LegacyServerSrcMigration.cs

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 19, 2025

Warning

Rate limit exceeded

@msanatan has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 12 minutes and 44 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between a947c9f and 6b8ffd3.

📒 Files selected for processing (1)
  • MCPForUnity/Editor/Migrations/LegacyServerSrcMigration.cs (1 hunks)
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • Now that warnings are always emitted on any failure, consider whether using McpLog.Warn for every individual message is too noisy for typical users and whether some messages should stay at Info with a single higher-level warning summarizing the failures.
  • The new condition if (summary.FailureCount > 0) changes behavior from also treating SuccessCount == 0 as a failure; if there are no detected clients (0 success, 0 failure), confirm that this is intended and that we don’t need a special-case log or handling for that scenario.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Now that warnings are always emitted on any failure, consider whether using `McpLog.Warn` for every individual message is too noisy for typical users and whether some messages should stay at `Info` with a single higher-level warning summarizing the failures.
- The new condition `if (summary.FailureCount > 0)` changes behavior from also treating `SuccessCount == 0` as a failure; if there are no detected clients (0 success, 0 failure), confirm that this is intended and that we don’t need a special-case log or handling for that scenario.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@msanatan msanatan merged commit 412cc00 into CoplayDev:main Dec 19, 2025
2 checks passed
@msanatan msanatan deleted the migration-improvement branch December 19, 2025 22:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant