Skip to content

Conversation

@RomneyDa
Copy link
Collaborator

@RomneyDa RomneyDa commented Nov 4, 2025

Description

Fixes #8382


Summary by cubic

Adds strict arg validation to the writeFile tool to prevent crashes when filepath or content are not strings. Safely generates diffs and previews, fixing #8382.

  • Bug Fixes
    • Validate filepath is a string; throw clear error if not.
    • Validate content is a string; default to "" when missing.
    • Use sanitized values for fs checks, diff creation, and preview.
    • Return normalized args (filepath, content) from preprocess.

Written for commit 01bef16. Summary will update automatically on new commits.

@RomneyDa RomneyDa requested a review from a team as a code owner November 4, 2025 07:52
@RomneyDa RomneyDa requested review from Patrick-Erichsen and removed request for a team November 4, 2025 07:52
@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Nov 4, 2025
@github-actions
Copy link

github-actions bot commented Nov 4, 2025

✅ Review Complete

Code Review Summary

⚠️ Continue API authentication failed. Please check your CONTINUE_API_KEY.


Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 1 file

Prompt for AI agents (all 1 issues)

Understand the root cause of the following 1 issues and fix them.


<file name="extensions/cli/src/tools/writeFile.ts">

<violation number="1" location="extensions/cli/src/tools/writeFile.ts:113">
The normalized `filepath`/`content` values are only returned in the new-file path, but when the file already exists this branch still returns the original `args`, so `run` receives `content` as `undefined` and `fs.writeFileSync` throws. Please return the sanitized args in both branches.</violation>
</file>

React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai to give feedback, ask questions, or re-run the review.


return {
args,
args: {
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Nov 4, 2025

Choose a reason for hiding this comment

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

The normalized filepath/content values are only returned in the new-file path, but when the file already exists this branch still returns the original args, so run receives content as undefined and fs.writeFileSync throws. Please return the sanitized args in both branches.

Prompt for AI agents
Address the following comment on extensions/cli/src/tools/writeFile.ts at line 113:

<comment>The normalized `filepath`/`content` values are only returned in the new-file path, but when the file already exists this branch still returns the original `args`, so `run` receives `content` as `undefined` and `fs.writeFileSync` throws. Please return the sanitized args in both branches.</comment>

<file context>
@@ -103,7 +110,10 @@ export const writeFileTool: Tool = {
 
     return {
-      args,
+      args: {
+        filepath,
+        content,
</file context>
Fix with Cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S This PR changes 10-29 lines, ignoring generated files.

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

[Continue CLI] Cannot read properties of undefined (reading 'split').

2 participants