[GH-ISSUE #3010] [Issue]: Custom tool can be created with a name that collides with a built-in tool; it is silently dropped with no user-facing error #1583

Closed
opened 2026-10-21 05:39:52 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @kolacheee on GitHub (Jun 29, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/3010

Originally assigned to: @SpicyMarinara on GitHub.

What's wrong

The create route validates a custom tool's name only against the snake_case regex and against OTHER custom tools (storage.getByName). It never checks the name against the built-in tool ids (roll_dice, search_lorebook, write_chat_variable, spotify_play, edit_chat_message, etc.). A user can therefore create and enable a custom tool named e.g. roll_dice. The create returns 201, the tool persists, and it appears enabled in the UI. But at generation time loadToolDefinitions() registers all built-ins first, then iterates enabled custom tools; when a custom tool's name is already registered, it is skipped with only a server-side logger.warn and continue. The custom tool's executionType/webhookUrl/scriptBody/staticResult are never wired up, so the model only ever invokes the built-in implementation. The user gets a tool that looks active but silently never runs — no error in the API response, no UI feedback. PATCH has the same gap: a valid tool can be renamed to a built-in name and reintroduce the dead tool.

How to reproduce (try it yourself)

  1. POST /custom-tools with {"name":"roll_dice","description":"my custom roller","executionType":"static","staticResult":"hi"} (or create via the Tool Editor with name roll_dice).
  2. The request returns 201 with the stored tool (regex passes; getByName finds no existing CUSTOM tool named roll_dice).
  3. Enable the tool and use it in a chat with tools on.

You'll see: the model's roll_dice calls execute the built-in dice roller, never the custom static result. The only trace is a server log: Skipping custom tool "roll_dice" because it collides with existing built-in tool.

Expected: the create (and rename) is rejected with a clear error explaining the name is reserved.

Where it is

packages/server/src/routes/custom-tools.routes.ts:30-42 (POST create) and :44-56 (PATCH, which also never re-checks the name); silent skip at packages/server/src/services/generation/tool-resolution-runtime.ts:292-302. Supporting: regex-only validation at packages/shared/src/schemas/custom-tool.schema.ts:8-13; getByName scoped to the custom-tools table at packages/server/src/services/storage/custom-tools.storage.ts:30-33; the 17 built-ins at packages/shared/src/features/function-calls/tool-registry.generated.ts:23-41.

What's happening

Name-uniqueness enforcement at create/update time only covers custom tools, not the reserved built-in namespace. BUILT_IN_TOOLS (importable from @marinara-engine/shared) is never consulted in the route or storage layer. The downstream resolver treats the collision as a non-fatal skip (continue + logger.warn) rather than surfacing it, so the misconfiguration is invisible.

Suggested fix

Reject custom-tool names that collide with any reserved built-in tool id, on BOTH create and rename, surfacing a 409 the UI already displays.

  1. Import BUILT_IN_TOOLS in custom-tools.routes.ts:
import { createCustomToolSchema, updateCustomToolSchema, BUILT_IN_TOOLS } from "@marinara-engine/shared";
  1. In the POST handler, alongside the existing uniqueness check:
if (BUILT_IN_TOOLS.some((tool) => tool.name === input.name)) {
  return reply.status(409).send({ error: `"${input.name}" is a reserved built-in tool name.` });
}
  1. In the PATCH handler, when a name is being set/changed:
if (data.name !== undefined && BUILT_IN_TOOLS.some((tool) => tool.name === data.name)) {
  return reply.status(409).send({ error: `"${data.name}" is a reserved built-in tool name.` });
}

The api-client throws ApiError(status, body.error) on non-OK and ToolEditor surfaces err.message, so the message becomes visible UI feedback. No schema/client changes needed.

Regression avoided: the original suggested fix patched POST only, leaving PATCH-rename able to reintroduce the exact dead tool — the corrected fix closes both. Do NOT additionally import AGENT_ONLY_TOOL_NAMES: it is a private const in tool-resolution-runtime.ts (not exported, would fail to compile) and is redundant since all six agent-only names are already in BUILT_IN_TOOLS. The change is an additive validation gate that never touches execution paths and only rejects names matching one of the reserved built-in ids.


AI-investigated against v2.0.6; cited lines read and confirmed. Please verify before fixing.

Originally created by @kolacheee on GitHub (Jun 29, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/3010 Originally assigned to: @SpicyMarinara on GitHub. **What's wrong** The create route validates a custom tool's name only against the snake_case regex and against OTHER custom tools (`storage.getByName`). It never checks the name against the built-in tool ids (`roll_dice`, `search_lorebook`, `write_chat_variable`, `spotify_play`, `edit_chat_message`, etc.). A user can therefore create and enable a custom tool named e.g. `roll_dice`. The create returns 201, the tool persists, and it appears enabled in the UI. But at generation time `loadToolDefinitions()` registers all built-ins first, then iterates enabled custom tools; when a custom tool's name is already registered, it is skipped with only a server-side `logger.warn` and `continue`. The custom tool's executionType/webhookUrl/scriptBody/staticResult are never wired up, so the model only ever invokes the built-in implementation. The user gets a tool that looks active but silently never runs — no error in the API response, no UI feedback. PATCH has the same gap: a valid tool can be renamed to a built-in name and reintroduce the dead tool. **How to reproduce (try it yourself)** 1. `POST /custom-tools` with `{"name":"roll_dice","description":"my custom roller","executionType":"static","staticResult":"hi"}` (or create via the Tool Editor with name `roll_dice`). 2. The request returns 201 with the stored tool (regex passes; `getByName` finds no existing CUSTOM tool named `roll_dice`). 3. Enable the tool and use it in a chat with tools on. You'll see: the model's `roll_dice` calls execute the built-in dice roller, never the custom static result. The only trace is a server log: `Skipping custom tool "roll_dice" because it collides with existing built-in tool`. Expected: the create (and rename) is rejected with a clear error explaining the name is reserved. **Where it is** `packages/server/src/routes/custom-tools.routes.ts:30-42` (POST create) and `:44-56` (PATCH, which also never re-checks the name); silent skip at `packages/server/src/services/generation/tool-resolution-runtime.ts:292-302`. Supporting: regex-only validation at `packages/shared/src/schemas/custom-tool.schema.ts:8-13`; `getByName` scoped to the custom-tools table at `packages/server/src/services/storage/custom-tools.storage.ts:30-33`; the 17 built-ins at `packages/shared/src/features/function-calls/tool-registry.generated.ts:23-41`. **What's happening** Name-uniqueness enforcement at create/update time only covers custom tools, not the reserved built-in namespace. `BUILT_IN_TOOLS` (importable from `@marinara-engine/shared`) is never consulted in the route or storage layer. The downstream resolver treats the collision as a non-fatal skip (`continue` + `logger.warn`) rather than surfacing it, so the misconfiguration is invisible. **Suggested fix** Reject custom-tool names that collide with any reserved built-in tool id, on BOTH create and rename, surfacing a 409 the UI already displays. 1. Import `BUILT_IN_TOOLS` in `custom-tools.routes.ts`: ```ts import { createCustomToolSchema, updateCustomToolSchema, BUILT_IN_TOOLS } from "@marinara-engine/shared"; ``` 2. In the POST handler, alongside the existing uniqueness check: ```ts if (BUILT_IN_TOOLS.some((tool) => tool.name === input.name)) { return reply.status(409).send({ error: `"${input.name}" is a reserved built-in tool name.` }); } ``` 3. In the PATCH handler, when a name is being set/changed: ```ts if (data.name !== undefined && BUILT_IN_TOOLS.some((tool) => tool.name === data.name)) { return reply.status(409).send({ error: `"${data.name}" is a reserved built-in tool name.` }); } ``` The `api-client` throws `ApiError(status, body.error)` on non-OK and `ToolEditor` surfaces `err.message`, so the message becomes visible UI feedback. No schema/client changes needed. *Regression avoided:* the original suggested fix patched POST only, leaving PATCH-rename able to reintroduce the exact dead tool — the corrected fix closes both. Do NOT additionally import `AGENT_ONLY_TOOL_NAMES`: it is a private const in `tool-resolution-runtime.ts` (not exported, would fail to compile) and is redundant since all six agent-only names are already in `BUILT_IN_TOOLS`. The change is an additive validation gate that never touches execution paths and only rejects names matching one of the reserved built-in ids. --- *AI-investigated against v2.0.6; cited lines read and confirmed. Please verify before fixing.*
Author
Owner

@SpicyMarinara commented on GitHub (Jun 29, 2026):

Fixed in merged staging PR #3018.

<!-- gh-comment-id:4833017775 --> @SpicyMarinara commented on GitHub (Jun 29, 2026): Fixed in merged staging PR #3018.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#1583
No description provided.