fix: reject duplicate tool registration and add collision test#740
Merged
doroteaMonaco merged 1 commit intomofa-org:mainfrom Mar 2, 2026
Merged
fix: reject duplicate tool registration and add collision test#740doroteaMonaco merged 1 commit intomofa-org:mainfrom
doroteaMonaco merged 1 commit intomofa-org:mainfrom
Conversation
Contributor
Author
Contributor
Author
|
@doroteaMonaco thank you for merging this! Actually I have some open PRs in studio as well,( 54 46 ), whenever you're free please take a look at them! |
Collaborator
|
@Ishita-190 I'll review them as soon as possible. Thanks for contributing! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📋 Summary
This PR makes duplicate tool registration explicit by rejecting tools with names that are already registered. Previously,
ToolRegistry::register_with_sourcewould silently overwrite an existing tool and its associated source. This behavior has been changed to return an error instead.A unit test has also been added to ensure duplicate registration is rejected and registry state remains unchanged.
🔗 Related Issues
Closes #736
🧠 Context
register_with_sourcepreviously allowed silent overwriting:ToolSourcemetadata was overwritten,This behavior was unsafe and inconsistent with
hot_reload_plugin, which already rejects duplicate tool names and rolls back on conflict.🛠️ Changes
Duplicate registrations now return:
Updated implementation:
The added test now verifies:
🧪 How you Tested
The new behavior and test were verified locally:
📸 Screenshots / Logs (if applicable)
🧹 Checklist
Code Quality
cargo fmtruncargo clippypasses without warningsTesting
cargo testpasses locally without any errorDocumentation
PR Hygiene
main