Repository navigation
Fix Windows module resolution for reserved path segments - #64658
Daniel Rosenwasser (DanielRosenwasser) with Copilot wants to merge 7 commits into
Conversation
Co-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com>
Co-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com>
Daniel Rosenwasser (DanielRosenwasser)
left a comment
There was a problem hiding this comment.
Copilot address
| switch { | ||
| case len(path) >= 4 && (path[:4] == `\\?\` || path[:4] == `\\.\`): | ||
| case len(path) >= 2 && path[:2] == `\\`: | ||
| path = `\\?\UNC\` + path[2:] | ||
| default: | ||
| path = `\\?\` + path | ||
| } |
There was a problem hiding this comment.
Won't this allocate a ton? Find another way or a mitigation.
Co-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com>
|
Copilot does it make sense to just try realpath and do the scan only if that doesn't work? It's extremely uncommon to have these device names. |
Co-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com>
Yes—updated in 196c2ef. The original short/long path open runs first; only a failure triggers the reserved-component scan and extended-path retry. Successful ordinary realpaths now pay no scan cost. |
|
|
||
| // Works on directories too since https://go.dev/cl/405275. | ||
| h = windows.Handle(f.Fd()) | ||
| if err != nil && hasReservedPathComponent(path) { |
There was a problem hiding this comment.
Copilot leave a comment because this is some extremely subtle and annoying behavior.
There was a problem hiding this comment.
Added in 03cdc4c. The comment explains the normal namespace's device-name interpretation, why the extended namespace works, and why detection is deferred until the ordinary open fails.
Co-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com>
There was a problem hiding this comment.
🟢 Approval recommended
The implementation addresses the reported failure with focused Windows regression coverage and no identified correctness issues.
0 open findings
What changed in this PR
Fixes Windows realpath resolution for paths containing reserved device-name segments.
Changes:
- Retries failed realpath opens using extended Windows paths.
- Preserves drive, UNC, and device-path handling.
- Adds regression and reserved-name detection tests.
| File | Description |
|---|---|
tsc/internal/nativepath/realpath_windows.go |
Adds reserved-component detection and extended-path retry. |
tsc/internal/nativepath/realpath_windows_test.go |
Tests reserved directories, files, detection, and allocations. |
🧠 Review effort: Balanced
Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.
|
This fails linting and testing |
|
Copilot address the issues. From CI: |
Co-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com>
|
I don't think you can just remove Parallel without a nolint directive that says why |
Windows module resolution failed when a path contained a reserved device-name segment such as
con. This prevented declarations like the following from resolving:Changes
condirectory and a declaration file beneath it.con/directory segment (reserved device name) #64653