Accept either-platform absolute paths and fix v2 NewSession - #48
Merged
Merged
Conversation
Session paths are resolved by the agent, which may run on a different platform than the client. Client-side validation now accepts POSIX-absolute, drive-absolute, and UNC forms on any host while still rejecting drive-relative and root-relative paths. Host-local paths in clienthost and the v2 runner keep host-native filepath.IsAbs checks. v2 Connection.NewSession now uses the initialization from the most recent successful Initialize call instead of an empty one, which made the convenience wrapper fail before sending session/new. Fixes #45 Fixes #46 Refs #47
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.
Fixes #45. Fixes #46. Refs #47.
Problem
filepath.IsAbs, so it only accepted paths that are absolute for the client host. A Windows client could not address a POSIX agent withcwd/, and a POSIX client could not address a Windows agent (ACP session paths are validated with the host filepath.IsAbs, so "/" is rejected on Windows #45).v2.Connection.NewSession(ctx, directory)passed an emptyInitialization, so the convenience wrapper failed before sendingsession/new(v2 Connection.NewSession convenience wrapper can never succeed #46).Result
acpvalidate.AbsolutePathnow accepts paths absolute on either platform: POSIX (/dir), Windows drive-absolute (C:\dir,C:/dir), and UNC (\\server\share). Drive-relative (C:dir) and root-relative (\dir) paths remain rejected. The v1 facade, the v2 facade, andv2/mcpuse the shared check; host-local paths (clienthost, the v2 runner) keep host-nativefilepath.IsAbschecks.v2.Connection.NewSessionnow uses the initialization from the most recent successfulInitializecall and returns a clear error if called before initialization.Validation
go vet ./...go test -racefor the root,internal/acpvalidate,v2, andv2/mcppackagesTestNewSessionAcceptsPOSIXAbsoluteAgentPath,TestV2NewSessionUsesStoredInitialization,TestValidatePathsAcceptsAbsolutePathsFromEitherPlatform, plus the expandedTestAbsolutePathtable.Limits