Repository navigation
fix(mcp): expand ~ with os.UserHomeDir; run tests on Windows in CI - #209
Merged
Merged
Conversation
Four sites joined os.Getenv("HOME") to expand "~/". HOME is normally
unset on Windows, so "~/proj" became "proj" and filepath.Abs resolved it
against the server's cwd: either a spurious error or, worse, a confident
analysis of the wrong project. One helper, expandHome, now resolves "~",
"~/" and "~\" through os.UserHomeDir and returns an error naming the path
when no home directory is known.
Tests set HOME and USERPROFILE together (setHome) so they prove the same
behaviour on every OS; the old HOME-only tests passed on Windows by
supplying the variable Windows would not have. CI gains one Windows test
job (newest Go) so a whole platform is no longer asserted by a build.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NRaBgKRAZMX9hjbkkefA7T
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NRaBgKRAZMX9hjbkkefA7T
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Bug
mcp/main.goandmcp/topology.goexpanded~/by joiningos.Getenv("HOME"). On Windows HOME is normally unset, so~/projbecameprojandfilepath.Absresolved it against the server's cwd: a spurious "not accessible" error, or a confident analysis of the wrong project if a same-named directory sat next to the cwd.The issue counted 9 sites; main today has 4 (
validateProjectPath,handleListProjects,handleStatus,topologyProjectRoot). All four now route through one helper:based on
os.UserHomeDir(), handling~,~/and~\, and returning an error that names the path when no home directory is known rather than guessing relative to cwd.handleListProjectshad its own copy of the expansion before callingvalidateProjectPath; the copy is gone.Tests
TestExpandHome(mcp/main_test.go):~/x,~\x, bare~, untouched plain path, and the no-home case asserting an error that names the path.setHome(t, dir)sets HOME and USERPROFILE together; the three existing tests that set only HOME switched to it. Those passed on Windows before by supplying the variable Windows would not have.CI
The Test matrix gains one
windows-latestjob on Go 1.26 (the Build job already ran there, but no test ever did). ast-grep is installed there withpip, same as Linux. Unix-only tests already carry build tags ort.Skip; untouched.go build ./... && go test ./... && gofmt -l .clean on macOS. The Windows run is this PR's own CI. Its first run showed 124 pre-existing failures, none touching this change; they are listed by cause in #214, and the Windows job iscontinue-on-error(informational) until that list is empty.Fixes #139
🤖 Generated with Claude Code
https://claude.ai/code/session_01NRaBgKRAZMX9hjbkkefA7T