Fix: Ensure write_to_file creates empty files when content is empty #3871
+635
−179
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Early check for partial-block
Small typo
Missing path normalization
Related GitHub Issue
Closes: #3650
Description
This PR fixes a bug where the
write_to_file
tool would appear to succeed but fail to create files when the content parameter is empty. The tool now properly creates empty files when requested, ensuring consistent behavior regardless of content length.Key changes:
Test Procedure
Type of Change
src
or test files.Pre-Submission Checklist
npm run lint
).console.log
) has been removed.npm test
).main
branch.npm run changeset
if this PR includes user-facing changes or dependency updates.Documentation Updates
Get in Touch
Discord:
ruakij
Important
Fixes
writeToFileTool
to handle empty content correctly, adds error handling, refactors for clarity, and introduces comprehensive unit tests.writeToFileTool
to create files even when content is empty inwriteToFileTool.ts
.validateAccess
,checkFileExists
,preprocessContent
,createMessageProps
, andhandleDiffViewUpdate
inwriteToFileTool.ts
.writeToFileTool.test.ts
with unit tests for parameter validation, access control, file existence, content preprocessing, file operations, partial block handling, user interaction, and error handling.This description was created by
for 06d8bbb. You can customize this summary. It will automatically update as commits are pushed.