From ce2a4db6cbbfe945b958885cf6f7338cc88971a8 Mon Sep 17 00:00:00 2001 From: Virgil Date: Sat, 4 Apr 2026 00:24:52 +0000 Subject: [PATCH] fix(process): reject empty start command --- service.go | 4 ++++ service_test.go | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/service.go b/service.go index 6ed34dc..1bca64b 100644 --- a/service.go +++ b/service.go @@ -102,6 +102,10 @@ func (s *Service) Start(ctx context.Context, command string, args ...string) (*P // StartWithOptions spawns a process with full configuration. func (s *Service) StartWithOptions(ctx context.Context, opts RunOptions) (*Process, error) { + if opts.Command == "" { + return nil, coreerr.E("Service.StartWithOptions", "command is required", nil) + } + id := fmt.Sprintf("proc-%d", s.idCounter.Add(1)) startedAt := time.Now() diff --git a/service_test.go b/service_test.go index e7b8323..f477fab 100644 --- a/service_test.go +++ b/service_test.go @@ -63,6 +63,14 @@ func TestService_Start(t *testing.T) { assert.Error(t, err) }) + t.Run("empty command is rejected", func(t *testing.T) { + svc, _ := newTestService(t) + + _, err := svc.StartWithOptions(context.Background(), RunOptions{}) + require.Error(t, err) + assert.Contains(t, err.Error(), "command is required") + }) + t.Run("with working directory", func(t *testing.T) { svc, _ := newTestService(t)