fix(vscode): add path validation to ACP writeTextFile handler#2305
fix(vscode): add path validation to ACP writeTextFile handler#2305ossaidqadri wants to merge 1 commit intoQwenLM:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Validate path parameter | ||
| if (!params.path || typeof params.path !== 'string') { | ||
| const error = new Error( | ||
| `Invalid path: path must be a non-empty string, received ${JSON.stringify(params.path)}`, |
There was a problem hiding this comment.
JSON.stringify(params.path) can itself throw (e.g., when params.path is a bigint), which would replace the intended validation error with a different exception. Use a non-throwing representation for the received value (e.g., String(params.path) or a safe-stringify helper that handles BigInt/circular structures) so the validation reliably throws the intended "Invalid path" error.
| `Invalid path: path must be a non-empty string, received ${JSON.stringify(params.path)}`, | |
| `Invalid path: path must be a non-empty string, received ${String(params.path)}`, |
- Use String() instead of JSON.stringify() to avoid throwing on bigint
- Preserve original error details using { cause: error } option
- Add tests for non-string path values (number, null, undefined)
Addresses Copilot review comments on PR QwenLM#2305
Review Comments Resolved ✅All 3 Copilot review comments have been addressed:
All changes have been pushed and tests pass (19/19). |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@ossaidqadri Thank you for your contribution. It seems that there is still a small conflict. Can you help me solve it again? |
e14d3b5 to
69043d1
Compare
|
@yiliang114 I've resolved the merge conflict by rebasing the branch on the latest upstream/main. The PR now includes:
The branch is now up to date with main and should merge cleanly. Could you please try merging again? Thanks for reviewing! |
69043d1 to
13e242d
Compare
|
@yiliang114 reminder to look on this |
|
We reproduced the issue and found that the "invalid path" on the Zed editor side was caused by permission check of the editor itself. It is by design, no need to fix. The other issue has been resolved in another PR already. |
TLDR
Fixes #2294 - Adds path validation to the ACP writeTextFile handler in the VSCode extension to prevent invalid path errors when creating new files.
Changes:
Dive Deeper
Problem
When using ACP's writeTextFile to create a new file that doesn't exist, the operation was failing with an invalid path error. The root cause was missing input validation in the handleWriteTextFile method.
Solution
Added comprehensive path validation in packages/vscode-ide-companion/src/services/acpFileHandler.ts:
Testing
All 16 tests pass including 10 new test cases covering:
Reviewer Test Plan
Testing Matrix
Linked issues
Fixes #2294