-
Notifications
You must be signed in to change notification settings - Fork 141
Do not convert volume target path to Windows style, implement tilde expansion for Windows #2488
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
Conversation
Since we deal with Linux containers, the volume target path should always be a Unix style path, even on Windows. Prior to this, the code would convert the target path to a Windows style path on Windows hosts due to the use of filepath.Clean. This PR changes the code to use path.Clean for the target instead, which always produces a Unix style path. Pre-existing validation ensures that the user cannot pass Windows style paths as input.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2488 +/- ##
=======================================
Coverage 55.66% 55.66%
=======================================
Files 295 295
Lines 28086 28086
=======================================
Hits 15635 15635
- Misses 11029 11030 +1
+ Partials 1422 1421 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@claude please review this |
|
Claude finished @danbarr's task —— View job Code ReviewTodo List
SummaryThis PR makes important fixes to path handling for volume mounts in ToolHive, addressing two key issues:
Detailed Review✅ Strengths
🔍 Observations & Questions1. Removed
|
This is intentional - it is assumed that that Unix shells will expand tilde for us. |
Since we deal with Linux containers, the volume target path should always be a Unix style path, even on Windows. Prior to this, the code would convert the target path to a Windows style path on Windows hosts due to the use of filepath.Clean. This PR changes the code to use path.Clean for the target instead, which always produces a Unix style path. Pre-existing validation ensures that the user cannot pass Windows style paths as input.
Another issue which was discovered by @danbarr as part of this was inconsistent handling of tilde expansion (i.e. converting
~/footo an absolute path with the user's home folder). This was exacerbated by ToolHive using hand-rolled code to do absolute path expansion when there is a function in the Go standard library to do this. The new code explicltly checks to see if the path starts with~on Windows hosts, replaces it with the contents of theUSERPROFILEenv var if true, and then uses the Go standard library to convert to an absolute path.