From 0b91b576ef465bbc360853b46061ecba4a73ecd0 Mon Sep 17 00:00:00 2001 From: alu Date: Mon, 2 Mar 2026 15:37:11 -0800 Subject: [PATCH] fix: fail tools-list when tools array is empty An empty array ([]) is truthy in TypeScript, so the tools-list check incorrectly passed even when no tools were returned. Also refactor the nested if/else into a flat if/else-if chain for readability. Co-Authored-By: Claude Sonnet 4.6 --- src/scenarios/server/tools.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/scenarios/server/tools.ts b/src/scenarios/server/tools.ts index 7ecbfdd..72e3beb 100644 --- a/src/scenarios/server/tools.ts +++ b/src/scenarios/server/tools.ts @@ -39,11 +39,11 @@ export class ToolsListScenario implements ClientScenario { const errors: string[] = []; if (!result.tools) { errors.push('Missing tools array'); + } else if (!Array.isArray(result.tools)) { + errors.push('tools is not an array'); + } else if (result.tools.length === 0) { + errors.push('tools array is empty'); } else { - if (!Array.isArray(result.tools)) { - errors.push('tools is not an array'); - } - result.tools.forEach((tool, index) => { if (!tool.name) errors.push(`Tool ${index}: missing name`); if (!tool.description)