diff options
| author | Peter Stone <thepeterstone@gmail.com> | 2026-03-03 21:22:30 +0000 |
|---|---|---|
| committer | Peter Stone <thepeterstone@gmail.com> | 2026-03-03 21:22:30 +0000 |
| commit | 3962597950421e422b6e1ce57764550f5600ded6 (patch) | |
| tree | ef376c4c192293869fe408cb27abe6bba9e1fa32 /internal/executor/claude_test.go | |
| parent | e8d1b80bd504088a7535e6045ab77f1ddd3b3d43 (diff) | |
Fix working_dir failures: validate path early, remove hardcoded /root
executor/claude.go: stat working_dir before cmd.Start() so a missing
or inaccessible directory surfaces as a clear error
("working_dir \"/bad/path\": no such file or directory") rather than
an opaque chdir failure wrapped in "starting claude".
api/elaborate.go: replace the hardcoded /root/workspace/claudomator
path with buildElaboratePrompt(workDir) which injects the server's
actual working directory (from os.Getwd() at startup). Empty workDir
tells the model to leave working_dir blank.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/executor/claude_test.go')
| -rw-r--r-- | internal/executor/claude_test.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/internal/executor/claude_test.go b/internal/executor/claude_test.go index fa81b09..ac6aabf 100644 --- a/internal/executor/claude_test.go +++ b/internal/executor/claude_test.go @@ -1,9 +1,13 @@ package executor import ( + "context" + "io" + "log/slog" "strings" "testing" + "github.com/thepeterstone/claudomator/internal/storage" "github.com/thepeterstone/claudomator/internal/task" ) @@ -166,6 +170,30 @@ func TestClaudeRunner_BuildArgs_PreambleBashNotDuplicated(t *testing.T) { } } +func TestClaudeRunner_Run_InaccessibleWorkingDir_ReturnsError(t *testing.T) { + r := &ClaudeRunner{ + BinaryPath: "true", // would succeed if it ran + Logger: slog.New(slog.NewTextHandler(io.Discard, nil)), + LogDir: t.TempDir(), + } + tk := &task.Task{ + Claude: task.ClaudeConfig{ + WorkingDir: "/nonexistent/path/does/not/exist", + SkipPlanning: true, + }, + } + exec := &storage.Execution{ID: "test-exec"} + + err := r.Run(context.Background(), tk, exec) + + if err == nil { + t.Fatal("expected error for inaccessible working_dir, got nil") + } + if !strings.Contains(err.Error(), "working_dir") { + t.Errorf("expected 'working_dir' in error, got: %v", err) + } +} + func TestClaudeRunner_BinaryPath_Default(t *testing.T) { r := &ClaudeRunner{} if r.binaryPath() != "claude" { |
