fix: tools.json registry corruption on push-create and delete#97
Open
aicayzer wants to merge 1 commit into
Open
fix: tools.json registry corruption on push-create and delete#97aicayzer wants to merge 1 commit into
aicayzer wants to merge 1 commit into
Conversation
- pushTools read response.toolId when creating a tool, but the API response field is id, so a fabricated tool_<timestamp> ID was always saved to tools.json and every subsequent push of that tool targeted a nonexistent ID; use response.id and skip saving if it is absent - deleteTool ran its remove-from-registry block twice, so the second splice silently dropped an unrelated entry from tools.json whenever the deleted tool was not the last one
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.
Two registry bugs in
tools push/tools delete, both verified with failing tests before the fix.Create via push stores a fabricated ID
pushToolsreadsresponse.toolIdwhen creating a tool, butToolResponseModelhasid(addToolalready usesresponse.id). The fallback|| `tool_${Date.now()}`therefore always fires and tools.json ends up with an ID liketool_1781206975927. Every subsequent push of that tool targets a nonexistent ID.Fix: use
response.id; if it's ever absent, log and skip saving instead of fabricating one.Delete removes a second, unrelated entry
deleteToolruns its remove-from-tools.json splice+write block twice (duplicated code). The secondsplice(toolIndex, 1)removes whatever entry shifted into that index, so deleting any tool that isn't last silently drops another tool from the registry. With two tools registered, deleting one empties tools.json.Fix: removed the duplicated block.
Tests
Two tests (
registry.test.ts) driving the realpushTools/deleteToolagainst a temp directory with the API layer mocked. Both red before the fix (fabricatedtool_1781206975927stored; registry emptied), green after. Full suite 204/204, lint and build clean.