Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

Githubguy132010
Copy link

@Githubguy132010 Githubguy132010 commented May 13, 2025

Closes #3533

This pull request updates the writeToFileTool function in src/core/tools/writeToFileTool.ts to improve the handling of the newContent parameter by explicitly checking for undefined instead of falsy values. This ensures more precise validation and avoids potential issues with empty strings or other falsy but valid inputs.

Improvements to parameter validation:

  • Updated the condition in the initial if statement to explicitly check if newContent is undefined instead of relying on a general falsy check. This ensures that valid but falsy values (e.g., empty strings) are not incorrectly treated as invalid.
  • Modified a subsequent if statement to use newContent === undefined for consistency and to avoid unintended behavior when newContent is a valid falsy value.

Important

Update writeToFileTool to explicitly check for undefined in newContent to handle empty strings and other falsy values correctly.

  • Behavior:
    • Update writeToFileTool in writeToFileTool.ts to explicitly check newContent === undefined instead of falsy check.
    • Ensures empty strings and other falsy values are valid inputs.
  • Validation:
    • Modify initial if statement to use newContent === undefined.
    • Change subsequent if statement for consistency and correct handling of falsy values.

This description was created by Ellipsis for 2fcaffa. You can customize this summary. It will automatically update as commits are pushed.

Copy link

changeset-bot bot commented May 13, 2025

⚠️ No Changeset found

Latest commit: 3b2a3f8

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. bug Something isn't working labels May 13, 2025
@KJ7LNW
Copy link

KJ7LNW commented May 13, 2025

nice. add a test and also check for any .trim()'s

@hannesrudolph
Copy link
Collaborator

@Githubguy132010 can you please update this to follow and issues first approach?

@hannesrudolph hannesrudolph moved this from New to PR [Draft/WIP] in Roo Code Roadmap May 14, 2025
@KJ7LNW
Copy link

KJ7LNW commented May 14, 2025

@Githubguy132010 can you please update this to follow and issues first approach?

There is, see #3533 and @Githubguy132010 mentioned it above ^^

@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:XS This PR changes 0-9 lines, ignoring generated files. labels May 15, 2025
@Githubguy132010
Copy link
Author

nice. add a test and also check for any .trim()'s

Ok. I did that.

@KJ7LNW
Copy link

KJ7LNW commented May 15, 2025

I think generally while adding tests for the feature is great, BUT there are so many tests that it is impossible for me to tell what you are testing specific to this pull request.

warning: AI tests have a tendency to create so much mocking and that by the time it tests what it expects it basically becomes a very elaborate check for 1==1 because it has mocked up what it expects and then it expects what it mocked

review all tests to make sure that this is not the case

@hannesrudolph hannesrudolph moved this from PR [Draft/WIP] to PR [Pre Approval Review] in Roo Code Roadmap May 16, 2025
@hannesrudolph hannesrudolph moved this from New to PR [Pre Approval Review] in Roo Code Roadmap May 20, 2025
@hannesrudolph hannesrudolph moved this from PR [Needs Review] to TEMP in Roo Code Roadmap May 26, 2025
@daniel-lxs daniel-lxs moved this from TEMP to PR [Needs Review] in Roo Code Roadmap May 27, 2025
@daniel-lxs
Copy link
Collaborator

To keep in mind during review: This PR seems to be trying to solve the same issue as PR #3871.

@KJ7LNW
Copy link

KJ7LNW commented May 27, 2025

@daniel-lxs LGTM

@hannesrudolph hannesrudolph added the Followup Needs followup from support or code team label May 27, 2025
@daniel-lxs daniel-lxs moved this from PR [Needs Preliminary Review] to PR [Needs Review] in Roo Code Roadmap May 27, 2025
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Jun 17, 2025
@daniel-lxs
Copy link
Collaborator

@KJ7LNW
Should be working, I am not sure about the side-effects of this or if this issue is even worth solving considering the implications.

@daniel-lxs daniel-lxs moved this from Triage to PR [Changes Requested] in Roo Code Roadmap Jun 17, 2025
@daniel-lxs daniel-lxs moved this from PR [Changes Requested] to PR [Needs Prelim Review] in Roo Code Roadmap Jun 17, 2025
@daniel-lxs daniel-lxs removed the status in Roo Code Roadmap Jun 17, 2025
@daniel-lxs daniel-lxs moved this to PR [Needs Prelim Review] in Roo Code Roadmap Jun 17, 2025
@hannesrudolph hannesrudolph added PR - Needs Preliminary Review and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Jun 17, 2025
@KJ7LNW
Copy link

KJ7LNW commented Jun 17, 2025

Thank you @daniel-lxs . I just tested it and the result looks good.

@KJ7LNW
Copy link

KJ7LNW commented Jun 17, 2025

Regarding possible side effects: if there are any, then those are actually bugs elsewhere in the application.

From a programming perspective, the parser's job is to parse, and that's it: it should provide exactly what was parsed to any tooling and the tools should do whatever they need to do with the result. If the tool receives something unexpected then it is the tool's job to clean it up, not the parser.

That said, this is a production application, so it could be a good idea to run this through a simple eval and see if any breaks catastrophically, but I do not expect it because the model does a pretty good job of using the correct white space and all of the examples I can remember.

Do you have a quick way to tell the eval system "run against PR 3550" ?

@KJ7LNW
Copy link

KJ7LNW commented Jun 17, 2025

@samhvw8 you have been working on the V3 parser - do you have any commentary related to possible side effects from d24d3b1 ?

please also see my comment in the previous message.

@daniel-lxs
Copy link
Collaborator

I'll run some Integration tests on this tomorrow, see if anything pops up.

@daniel-lxs
Copy link
Collaborator

It seems that as a side effect the files created always have a new line at the beginning, making the write_to_file tool integration test fail:

  2) Roo Code write_to_file Tool
       Should create nested directories when writing file:

      AssertionError [ERR_ASSERTION]: File content should match
+ actual - expected

+ '\nFile in nested directory\n'
- 'File in nested directory'

      + expected - actual

      -
      -File in nested directory
      +File in nested directory

I'll check if I can fix this later.

@daniel-lxs daniel-lxs moved this from PR [Needs Prelim Review] to PR [Changes Requested] in Roo Code Roadmap Jun 17, 2025
@daniel-lxs daniel-lxs moved this from PR [Changes Requested] to PR [Needs Prelim Review] in Roo Code Roadmap Jun 17, 2025
@daniel-lxs daniel-lxs moved this from PR [Needs Prelim Review] to PR [Changes Requested] in Roo Code Roadmap Jun 17, 2025
…erve newlines in content parameters while stripping leading and trailing newlines
Copy link
Collaborator

@daniel-lxs daniel-lxs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed the side-effects by trimming the first and last newlines.

LGTM

@daniel-lxs daniel-lxs moved this from PR [Changes Requested] to PR [Needs Review] in Roo Code Roadmap Jun 23, 2025
@mrubens mrubens merged commit 245c8f3 into RooCodeInc:main Jun 23, 2025
10 checks passed
@github-project-automation github-project-automation bot moved this from PR [Needs Review] to Done in Roo Code Roadmap Jun 23, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Jun 23, 2025
@Githubguy132010 Githubguy132010 deleted the fix-write-to-file-tool branch June 24, 2025 05:03
cte pushed a commit that referenced this pull request Jun 24, 2025
)

* Fix: Allow write_to_file to handle newline-only and empty content

* fix: update writeToFileTool to return early without error on missing or empty parameters

* fix: preserve newlines in content parameters and update error handling in writeToFileTool tests

* fix: update parseAssistantMessage and parseAssistantMessageV2 to preserve newlines in content parameters while stripping leading and trailing newlines

---------

Co-authored-by: Daniel Riccio <ricciodaniel98@gmail.com>
Alorse pushed a commit to Alorse/Roo-Code that referenced this pull request Jun 27, 2025
…oCodeInc#3550)

* Fix: Allow write_to_file to handle newline-only and empty content

* fix: update writeToFileTool to return early without error on missing or empty parameters

* fix: preserve newlines in content parameters and update error handling in writeToFileTool tests

* fix: update parseAssistantMessage and parseAssistantMessageV2 to preserve newlines in content parameters while stripping leading and trailing newlines

---------

Co-authored-by: Daniel Riccio <ricciodaniel98@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working lgtm This PR has been approved by a maintainer PR - Changes Requested size:M This PR changes 30-99 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Files with only newlines cannot be created using write_to_file

5 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.