-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Description
What's the bug?
In local mode, the create-function and update-function MCP tools read a code file via fs.readFile() but never validate that the content is non-empty. An empty or whitespace-only file is silently sent to the API, which either fails with a confusing backend error or creates a broken function.
create-function (src/shared/tools/functions.ts, line 78-86):
- Reads
args.codeFilesuccessfully - Sends the content directly to the API without checking if it's empty
uploadFunctionRequestSchemadefinescode: z.string().min(1), but the tool omits thecodefield and defines its own without themin(1)constraint
update-function (src/shared/tools/functions.ts, line 210-218):
- Same issue -- reads file, no empty check
updateFunctionRequestSchemadefinescodeas an optional plain string with nomin(1), so even the schema would not catch an empty string here
How to reproduce
- Create an empty file:
touch empty.ts - Call
create-functionwithcodeFile: "empty.ts" - The tool sends an empty string as the function code
Proposed fix
Add empty file validation after the successful fs.readFile() call in both local mode handlers:
code = await fs.readFile(args.codeFile, 'utf-8');
if (!code.trim()) {
throw new Error(`Code file '${args.codeFile}' is empty`);
}I'd like to work on this fix and have a PR ready.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels