From 60c3317ed9b0b6ddc94422b02e1b53e4f07d4b5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Pokorn=C3=BD?= Date: Wed, 16 Oct 2024 10:48:22 +0200 Subject: [PATCH] fix(code-interpreter): avoid crash when no files supplied (#97) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jan Pokorný --- src/tools/python/python.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/tools/python/python.ts b/src/tools/python/python.ts index cd001457..4c2c8131 100644 --- a/src/tools/python/python.ts +++ b/src/tools/python/python.ts @@ -116,9 +116,10 @@ export class PythonTool extends Tool { ): asserts rawInput is ToolInput { super.validateInput(schema, rawInput); - const fileNames = (rawInput.inputFiles as { filename: string }[]) - ?.map(({ filename }) => filename) - .filter(Boolean) as string[]; + const fileNames: string[] = + (rawInput.inputFiles as { filename: string }[]) + ?.map(({ filename }) => filename) + .filter(Boolean) ?? []; const diff = differenceWith(fileNames, unique(fileNames), isShallowEqual); if (diff.length > 0) { throw new ToolInputValidationError(