fix(process): reject empty start command

This commit is contained in:
Virgil 2026-04-04 00:24:52 +00:00
parent f98bbad5ac
commit ce2a4db6cb
2 changed files with 12 additions and 0 deletions

View file

@ -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()

View file

@ -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)