-
Notifications
You must be signed in to change notification settings - Fork 3.7k
fix: typecheck write file args #8585
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
base: main
Are you sure you want to change the base?
Conversation
|
✅ Review Complete Code Review Summary |
There was a problem hiding this 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: { |
There was a problem hiding this comment.
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>
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.
Written for commit 01bef16. Summary will update automatically on new commits.