-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Fix: Ensure write_to_file creates empty files when content is empty #3871
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: Ensure write_to_file creates empty files when content is empty #3871
Conversation
|
To keep in mind during review: This PR seems to be trying to solve the same issue as PR #3550. |
|
Pull requests to fix bugs need to be small and targeted, but looking at the differences this is huge and more than necessary to solve the problem. |
|
Hey @Ruakij, thank you for the contribution, I noticed that this PR introduces a lot of changes that might be outside of the scope of the issue you linked. Would it make sense to split this PR and create new issues for the other improvements you implemented? |
06d8bbb to
158c06c
Compare
158c06c to
8d37e71
Compare
Change validation from !newContent to newContent === undefined to allow empty strings while still rejecting undefined values.
8d37e71 to
ccf8938
Compare
|
I minimized the PR. |
|
@Ruakij |
|
Looks good to me, the requested changes were properly addressed. I'm aware that #3550 does pretty much the same thing however that PR currently has requested changes. |
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_filetool 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
srcor test files.Pre-Submission Checklist
npm run lint).console.log) has been removed.npm test).mainbranch.npm run changesetif this PR includes user-facing changes or dependency updates.Documentation Updates
Get in Touch
Discord:
ruakijImportant
Fixes
writeToFileToolto handle empty content correctly, adds error handling, refactors for clarity, and introduces comprehensive unit tests.writeToFileToolto create files even when content is empty inwriteToFileTool.ts.validateAccess,checkFileExists,preprocessContent,createMessageProps, andhandleDiffViewUpdateinwriteToFileTool.ts.writeToFileTool.test.tswith 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 06d8bbb50beb129a4edca457d34b8bdc3581c46e. You can customize this summary. It will automatically update as commits are pushed.