diff options
| author | Jacob MacDonald <[email protected]> | 2025-08-04 12:12:33 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-08-04 19:12:33 +0000 |
| commit | 5caf23d627829a28adb78f038170689155b17150 (patch) | |
| tree | 8c8165357a6ccce720ad6d2a9fef8a55d40936a1 /packages/core/src | |
| parent | d1bfba1abbd09e4c70220bc9d82f10b6f61c5b28 (diff) | |
remove unnecessary checks in WriteFileChecks.getDescription (#5526)
Diffstat (limited to 'packages/core/src')
| -rw-r--r-- | packages/core/src/tools/write-file.test.ts | 28 | ||||
| -rw-r--r-- | packages/core/src/tools/write-file.ts | 4 |
2 files changed, 29 insertions, 3 deletions
diff --git a/packages/core/src/tools/write-file.test.ts b/packages/core/src/tools/write-file.test.ts index 965e9476..fe662a02 100644 --- a/packages/core/src/tools/write-file.test.ts +++ b/packages/core/src/tools/write-file.test.ts @@ -13,7 +13,7 @@ import { vi, type Mocked, } from 'vitest'; -import { WriteFileTool } from './write-file.js'; +import { WriteFileTool, WriteFileToolParams } from './write-file.js'; import { FileDiff, ToolConfirmationOutcome, @@ -202,6 +202,32 @@ describe('WriteFileTool', () => { `Path is a directory, not a file: ${dirAsFilePath}`, ); }); + + it('should return error if the content is null', () => { + const dirAsFilePath = path.join(rootDir, 'a_directory'); + fs.mkdirSync(dirAsFilePath); + const params = { + file_path: dirAsFilePath, + content: null, + } as unknown as WriteFileToolParams; // Intentionally non-conforming + expect(tool.validateToolParams(params)).toMatch( + `params/content must be string`, + ); + }); + }); + + describe('getDescription', () => { + it('should return error if the file_path is empty', () => { + const dirAsFilePath = path.join(rootDir, 'a_directory'); + fs.mkdirSync(dirAsFilePath); + const params = { + file_path: '', + content: '', + }; + expect(tool.getDescription(params)).toMatch( + `Model did not provide valid parameters for write file tool, missing or empty "file_path"`, + ); + }); }); describe('_getCorrectedFileContent', () => { diff --git a/packages/core/src/tools/write-file.ts b/packages/core/src/tools/write-file.ts index 470adf31..1cb1a917 100644 --- a/packages/core/src/tools/write-file.ts +++ b/packages/core/src/tools/write-file.ts @@ -131,8 +131,8 @@ export class WriteFileTool } getDescription(params: WriteFileToolParams): string { - if (!params.file_path || !params.content) { - return `Model did not provide valid parameters for write file tool`; + if (!params.file_path) { + return `Model did not provide valid parameters for write file tool, missing or empty "file_path"`; } const relativePath = makeRelative( params.file_path, |
