Skip to content

Fix error when opening file outside of any workspace #3815

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

Closed
wants to merge 4 commits into from

Conversation

Flamefire
Copy link

Description

path.relative doesn't allow undefined as its parameter(s)
However this happens when getWorkspaceDirs returns an empty array which causes an error:

TypeError: The "from" argument must be of type string. Received undefined

So extract the first element and check if it is valid/set before further processing.

Testing instructions

Open a single file in VSCode and observe that the error message is no longer shown

`path.relative` doesn't allow `undefined` as its parameter(s)
However this happens when `getWorkspaceDirs` returns an empty array.
So extract the first element and check if it is valid/set before further processing.
Copy link

netlify bot commented Jan 22, 2025

Deploy Preview for continuedev ready!

Name Link
🔨 Latest commit d090dd5
🔍 Latest deploy log https://app.netlify.com/sites/continuedev/deploys/67c7fd261f4df800089bc8c0
😎 Deploy Preview https://deploy-preview-3815--continuedev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@sestinj sestinj requested a review from RomneyDa January 27, 2025 21:36
Flamefire and others added 2 commits February 2, 2025 11:32
Workspaces are Uris so path.relative would be unreliable.
RomneyDa
RomneyDa previously approved these changes Mar 4, 2025
@Flamefire
Copy link
Author

I missed an instance of the renamed variable in the debug message. Fixed

@RomneyDa
Copy link
Collaborator

Some sweeping changes with ignore logic fixed this as a side effect, and now neither path.relative or findUriInDirs applies. #4531

@Flamefire thank you for the contribution and apologies for the delays and misfires.

@RomneyDa RomneyDa closed this Mar 10, 2025
@Flamefire
Copy link
Author

I see, there is a function factored out and that uses the findUriInDirs equivalently as I did here. For reference:

const { foundInDir: rootDir, uri } = findUriInDirs(fileUri, rootDirUris);

Thanks for letting me know!

@Flamefire Flamefire deleted the patch-2 branch March 11, 2025 08:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants