Skip to content

fix: tools.json registry corruption on push-create and delete#97

Open
aicayzer wants to merge 1 commit into
elevenlabs:mainfrom
aicayzer:fix/tools-registry-corruption
Open

fix: tools.json registry corruption on push-create and delete#97
aicayzer wants to merge 1 commit into
elevenlabs:mainfrom
aicayzer:fix/tools-registry-corruption

Conversation

@aicayzer

Copy link
Copy Markdown

Two registry bugs in tools push/tools delete, both verified with failing tests before the fix.

Create via push stores a fabricated ID

pushTools reads response.toolId when creating a tool, but ToolResponseModel has id (addTool already uses response.id). The fallback || `tool_${Date.now()}` therefore always fires and tools.json ends up with an ID like tool_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

deleteTool runs its remove-from-tools.json splice+write block twice (duplicated code). The second splice(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 real pushTools/deleteTool against a temp directory with the API layer mocked. Both red before the fix (fabricated tool_1781206975927 stored; registry emptied), green after. Full suite 204/204, lint and build clean.

- 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
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