[ty] Fix playground crashes when accessing vendored files with leading slashes#20661
Conversation
|
|
Thanks for putting up with my silly. A couple things:
Edit: Looking at the docs more, for
So if the playground is being hosted on a Unix machine (which I image it is), that branch would be unreachable, but it could still crash on windows. |
|
What's the code path where we call into |
The crash originated from the playground’s vendored URI flow. The path is:
ruff/crates/ty_wasm/src/lib.rs Lines 605 to 620 in caf48f4
ruff/crates/ruff_db/src/vendored.rs Lines 393 to 453 in 1f1c597 |
Yes, I think we should prevent the UI from creating vendored file paths similar to #20666 |
|
Would we like to remove the logic from |
| private getVendoredPath(uri: Uri): string { | ||
| // Monaco parses "vendored://stdlib/typing.pyi" as authority="stdlib", path="/typing.pyi" | ||
| // We need to reconstruct the full path | ||
| return uri.authority ? `${uri.authority}${uri.path}` : uri.path; | ||
| const fullPath = uri.authority ? `${uri.authority}${uri.path}` : uri.path; | ||
| return fullPath.startsWith("/") ? fullPath.slice(1) : fullPath; | ||
| } |
There was a problem hiding this comment.
I don't think this is the right place. we need to prevent users from creating a file named vendored:// , similar to what we've done in #20666
Summary
Fixes astral-sh/ty#1290