fix(server): guard against undefined args in stripLoadingMessage and resolveAndExecute

https://sonarly.com/issue/28820?type=bug

The MCP tool execution chain crashes with a TypeError when `execute_tool` is called without an inner `arguments` field, because `stripLoadingMessage` destructures an undefined parameter. A secondary i18n issue causes log spam from uncompiled Lingui message catalogs.

Fix: Applied above. Two minimal defensive defaults preventing undefined from reaching destructure operations.
This commit is contained in:
Sonarly Claude Code 2026-04-19 20:48:14 +00:00
parent 75848ff8ea
commit 1f05071d72
2 changed files with 5 additions and 1 deletions

View file

@ -54,7 +54,7 @@ export const createExecuteToolTool = (
parameters: ExecuteToolInput,
options: ToolExecutionOptions,
): Promise<ToolOutput> => {
const { toolName, arguments: args } = parameters;
const { toolName, arguments: args = {} } = parameters;
if (excludeTools?.has(toolName)) {
return {

View file

@ -42,6 +42,10 @@ export const wrapJsonSchemaForExecution = (
export const stripLoadingMessage = <T extends Record<string, unknown>>(
parameters: T,
): Omit<T, 'loadingMessage'> => {
if (!parameters) {
return {} as Omit<T, 'loadingMessage'>;
}
const { loadingMessage: _, ...rest } = parameters;
return rest;