mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-07-22 07:41:23 -07:00
fix(core-tools): bypass LLM correction for JSON and IPYNB files in write_file and replace (#28223)
Co-authored-by: David Pierce <davidapierce@google.com>
This commit is contained in:
@@ -428,6 +428,39 @@ describe('WriteFileTool', () => {
|
||||
expect(result.error).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should not call ensureCorrectFileContent for .json files', async () => {
|
||||
const filePath = path.join(rootDir, 'config.json');
|
||||
const proposedContent = '{"key": "value\\nwith\\nescapes"}';
|
||||
const abortSignal = new AbortController().signal;
|
||||
|
||||
const result = await getCorrectedFileContent(
|
||||
mockConfig,
|
||||
filePath,
|
||||
proposedContent,
|
||||
abortSignal,
|
||||
);
|
||||
|
||||
expect(mockEnsureCorrectFileContent).not.toHaveBeenCalled();
|
||||
expect(result.correctedContent).toBe(proposedContent);
|
||||
});
|
||||
|
||||
it('should not call ensureCorrectFileContent for .ipynb files', async () => {
|
||||
const filePath = path.join(rootDir, 'notebook.ipynb');
|
||||
const proposedContent =
|
||||
'{"cells": [{"source": ["print(\\"hello\\\\n\\")"]}]}';
|
||||
const abortSignal = new AbortController().signal;
|
||||
|
||||
const result = await getCorrectedFileContent(
|
||||
mockConfig,
|
||||
filePath,
|
||||
proposedContent,
|
||||
abortSignal,
|
||||
);
|
||||
|
||||
expect(mockEnsureCorrectFileContent).not.toHaveBeenCalled();
|
||||
expect(result.correctedContent).toBe(proposedContent);
|
||||
});
|
||||
|
||||
it('should return error if reading an existing file fails (e.g. permissions)', async () => {
|
||||
const filePath = path.join(rootDir, 'unreadable_file.txt');
|
||||
const proposedContent = 'some content';
|
||||
|
||||
Reference in New Issue
Block a user