session: reject creation with non-existent cwd

When a session is created with a cwd that doesn't exist, all tool
execution fails with a confusing 'fork/exec landrun: no such file or
directory' because exec.Command sets cmd.Dir to the non-existent path.

Validate that cwd exists and is a directory at session creation time,
returning a clear error instead of allowing a broken session.

Also includes the earlier USER/NAMESPACE env export fix (agent.go,
shell.go) for the ollie-9p namespace path issue.
This commit is contained in:
Levi Neely 2026-07-31 09:28:44 +02:00
parent ae59151344
commit a73899bc2f
1 changed files with 5 additions and 0 deletions

View File

@ -63,6 +63,11 @@ func Create(rs *rootState, args []string) (string, error) {
if cwd == "" {
return "", fmt.Errorf("cwd is required (e.g. new cwd=/path/to/project)")
}
if info, err := os.Stat(cwd); err != nil {
return "", fmt.Errorf("cwd %q does not exist", cwd)
} else if !info.IsDir() {
return "", fmt.Errorf("cwd %q is not a directory", cwd)
}
sessID := name
if sessID == "" {