[GH-ISSUE #3016] [Issue]: Webhook/script tools can be saved with a blank URL/body — the editor lets you save a broken tool #1587

Closed
opened 2026-10-21 05:40:12 +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/3016

Originally assigned to: @SpicyMarinara on GitHub.

What's wrong

handleSave validates only name, description, and the script-enabled capability. It never requires that a webhook tool actually has a webhookUrl, or that a script tool has a scriptBody. Because the payload coerces a blank field to null (localExecType === "webhook" ? localWebhookUrl || null : null) and the persistence Zod schema accepts webhookUrl: z.string().url().nullable() (null is valid), a user can select Webhook, leave the URL empty, and Save succeeds with no error. The tool is then enabled and selectable, but every invocation returns { error: "No webhook URL configured" }. The same gap exists for script tools (empty body → { error: "No script body configured" }). The editor's Unsaved/Saved UI gives no indication the tool is non-functional.

How to reproduce (try it yourself)

  1. Open the Tool Editor for a new tool. Enter a valid name (e.g. call_api) and a description.
  2. Click the Webhook execution-type tile. Leave the Webhook URL field blank.
  3. Click Save.

You'll see: the save succeeds (payload webhookUrl becomes null; z.string().url().nullable() accepts null), the "Saved" flash shows, and the tool persists as enabled. When the model calls it, the tool result is { error: "No webhook URL configured" } every time, with no warning given at edit time.

Expected: Save is blocked with a clear error ("Webhook URL is required." / "Script body is required.") when the required field for the chosen execution type is empty.

Where it is

packages/client/src/components/agents/ToolEditor.tsx:157-184 (handleSave validation + payload). Supporting: nullable schema accepting null at packages/shared/src/schemas/custom-tool.schema.ts:17,19; no per-type guard in the route at packages/server/src/routes/custom-tools.routes.ts:30-56; runtime errors at packages/server/src/services/tools/tool-executor.ts:305 ("No webhook URL configured") and :341 ("No script body configured").

What's happening

Per-execution-type required-field validation is missing in the client. handleSave guards name/description/script-enabled but not the execution-type-specific required field. The blank value is silently turned into null by the localWebhookUrl || null coercion, and the server schema treats null webhookUrl as valid (it must, since non-webhook tools legitimately have null), so neither layer rejects the empty case.

Suggested fix

In handleSave, add two required-field guards immediately after the existing script-enabled check (before the const payload = {):

if (localExecType === "webhook" && !localWebhookUrl.trim()) {
  setSaveError("Webhook URL is required.");
  return;
}
if (localExecType === "script" && !localScriptBody.trim()) {
  setSaveError("Script body is required.");
  return;
}

Each guard is its own braced if-block with its own return, so it only fires for the matching execution type.

Regression avoided: do NOT add a staticResult requirement — a blank static result is valid and the executor returns the default "OK" (tool-executor.ts:302). Write each guard as a separate braced block; the original one-line form (if (cond) setSaveError(...); return;) would make the return execute unconditionally for every execution type, blocking ALL saves. Editing an existing valid webhook/script tool still saves (the field is populated), and server-side URL-format validation is untouched.


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/3016 Originally assigned to: @SpicyMarinara on GitHub. **What's wrong** `handleSave` validates only name, description, and the script-enabled capability. It never requires that a `webhook` tool actually has a `webhookUrl`, or that a `script` tool has a `scriptBody`. Because the payload coerces a blank field to null (`localExecType === "webhook" ? localWebhookUrl || null : null`) and the persistence Zod schema accepts `webhookUrl: z.string().url().nullable()` (null is valid), a user can select Webhook, leave the URL empty, and Save succeeds with no error. The tool is then enabled and selectable, but every invocation returns `{ error: "No webhook URL configured" }`. The same gap exists for script tools (empty body → `{ error: "No script body configured" }`). The editor's Unsaved/Saved UI gives no indication the tool is non-functional. **How to reproduce (try it yourself)** 1. Open the Tool Editor for a new tool. Enter a valid name (e.g. `call_api`) and a description. 2. Click the Webhook execution-type tile. Leave the Webhook URL field blank. 3. Click Save. You'll see: the save succeeds (payload `webhookUrl` becomes null; `z.string().url().nullable()` accepts null), the "Saved" flash shows, and the tool persists as enabled. When the model calls it, the tool result is `{ error: "No webhook URL configured" }` every time, with no warning given at edit time. Expected: Save is blocked with a clear error ("Webhook URL is required." / "Script body is required.") when the required field for the chosen execution type is empty. **Where it is** `packages/client/src/components/agents/ToolEditor.tsx:157-184` (`handleSave` validation + payload). Supporting: nullable schema accepting null at `packages/shared/src/schemas/custom-tool.schema.ts:17,19`; no per-type guard in the route at `packages/server/src/routes/custom-tools.routes.ts:30-56`; runtime errors at `packages/server/src/services/tools/tool-executor.ts:305` ("No webhook URL configured") and `:341` ("No script body configured"). **What's happening** Per-execution-type required-field validation is missing in the client. `handleSave` guards name/description/script-enabled but not the execution-type-specific required field. The blank value is silently turned into null by the `localWebhookUrl || null` coercion, and the server schema treats null `webhookUrl` as valid (it must, since non-webhook tools legitimately have null), so neither layer rejects the empty case. **Suggested fix** In `handleSave`, add two required-field guards immediately after the existing script-enabled check (before the `const payload = {`): ```ts if (localExecType === "webhook" && !localWebhookUrl.trim()) { setSaveError("Webhook URL is required."); return; } if (localExecType === "script" && !localScriptBody.trim()) { setSaveError("Script body is required."); return; } ``` Each guard is its own braced `if`-block with its own `return`, so it only fires for the matching execution type. *Regression avoided:* do NOT add a `staticResult` requirement — a blank static result is valid and the executor returns the default "OK" (tool-executor.ts:302). Write each guard as a separate braced block; the original one-line form (`if (cond) setSaveError(...); return;`) would make the `return` execute unconditionally for every execution type, blocking ALL saves. Editing an existing valid webhook/script tool still saves (the field is populated), and server-side URL-format validation is untouched. --- *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:4833019987 --> @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#1587
No description provided.