forked from cline/cline
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
fix: handle array paths from VSCode terminal profiles #7697
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Updated terminal profile interfaces to support string | string[] for path property - Added normalizeShellPath helper to safely extract first element from array paths - Modified isShellAllowed to handle both string and array inputs - Updated getWindowsShellFromVSCode, getMacShellFromVSCode, and getLinuxShellFromVSCode to use normalizeShellPath - Added comprehensive tests for array path handling Fixes #7695
- Created validateShellPath as a public API for shell path validation - Refactored internal validation logic into isShellAllowedInternal - Added comprehensive test coverage for all edge cases - Maintains backward compatibility with deprecated isShellAllowed - Handles arrays, strings, null, undefined, and nested arrays gracefully
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.
Reviewing my own code again. It's like grading my own homework, except the teacher is also me.
jr
approved these changes
Sep 5, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
bug
Something isn't working
Issue/PR - Triage
New issue. Needs quick review to confirm validity and assign labels.
lgtm
This PR has been approved by a maintainer
size:L
This PR changes 100-499 lines, ignoring generated files.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes the issue where VSCode's terminal profile configuration may return
path
as an array instead of a string, causing the error "The 'path' argument must be of type string. Received an instance of Array".Problem
As reported in #7695, the VSCode API may return
profile.path
as an array (e.g.,["C:\\Program Files\\PowerShell\\7\\pwsh.exe", "pwsh.exe"]
) instead of a string. This causes theisShellAllowed
function to fail since it expects a string parameter.Solution
path
can bestring | string[]
normalizeShellPath
helper to safely extract the first element from array pathsvalidateShellPath
export as a robust public API for shell validation that handles:isShellAllowedInternal
for cleaner separationisShellAllowed
functionTesting
Changes
src/utils/shell.ts
: Enhanced shell validation with array supportsrc/utils/__tests__/shell.test.ts
: Comprehensive test coverageFixes #7695
Important
Fixes handling of array paths in VSCode terminal profiles by normalizing paths and updating shell retrieval logic.
path
asstring[]
in VSCode terminal profiles, using first element if array.getShell()
inshell.ts
to handle array paths and fall back to defaults if necessary.normalizeShellPath()
to extract first element from array paths.getWindowsShellFromVSCode()
,getMacShellFromVSCode()
, andgetLinuxShellFromVSCode()
to usenormalizeShellPath()
.shell.spec.ts
for array paths, empty arrays, and fallback scenarios.getShell()
handles all edge cases, including invalid and nested arrays.This description was created by
for 332976b. You can customize this summary. It will automatically update as commits are pushed.