Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/envd/internal/services/filesystem/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (s Service) watchHandler(ctx context.Context, req *connect.Request[rpc.Watc
}

if !info.IsDir() {
return connect.NewError(connect.CodeInvalidArgument, fmt.Errorf("path %s not a directory: %w", watchPath, err))
return connect.NewError(connect.CodeInvalidArgument, fmt.Errorf("path %s is not a directory", watchPath))
}

// Check if path is on a network filesystem mount
Expand Down
2 changes: 1 addition & 1 deletion packages/envd/internal/services/filesystem/watch_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func (s Service) CreateWatcher(ctx context.Context, req *connect.Request[rpc.Cre
}

if !info.IsDir() {
return nil, connect.NewError(connect.CodeInvalidArgument, fmt.Errorf("path %s not a directory: %w", watchPath, err))
return nil, connect.NewError(connect.CodeInvalidArgument, fmt.Errorf("path %s is not a directory", watchPath))
}

// Check if path is on a network filesystem mount
Expand Down
22 changes: 22 additions & 0 deletions packages/envd/internal/services/filesystem/watch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,3 +215,25 @@ func TestCreateWatcherOnNetworkMount(t *testing.T) {
})
assert.NotEmpty(t, watcherID)
}

func TestCreateWatcher_NotADirectory(t *testing.T) {
t.Parallel()

u, err := user.Current()
require.NoError(t, err)

filePath := filepath.Join(t.TempDir(), "file.txt")
require.NoError(t, os.WriteFile(filePath, []byte("content"), 0o644))

svc := mockService()
ctx := authn.SetInfo(t.Context(), u)

_, err = svc.CreateWatcher(ctx, connect.NewRequest(&filesystem.CreateWatcherRequest{
Path: filePath,
}))
require.Error(t, err)
assert.Equal(t, connect.CodeInvalidArgument, connect.CodeOf(err))
assert.Contains(t, err.Error(), "is not a directory")
assert.NotContains(t, err.Error(), "%!w")
}