Skip to content

dagu enqueue shows go panic instead of proper error message when receiving no dag file. #2082

@struffel

Description

@struffel

Running dagu enqueue without actually giving it a workflow file is obviously wrong and should cause the program to quit with a proper error message. At the moment, it simply causes a panic and prints a stack trace:

# /opt/dagu/dagu enqueue                                                  
panic: runtime error: index out of range [0] with length 0

goroutine 1 [running]:
github.com/dagucloud/dagu/internal/cmd.loadDAGWithParams(0x3?, {0x876dd80?, 0x5?, 0x158559707b50?}, 0x98?)
        /home/runner/work/dagu/dagu/internal/cmd/start.go:299 +0xaf1
github.com/dagucloud/dagu/internal/cmd.runEnqueue(0x158559458840, {0x876dd80, 0x0, 0x0})
        /home/runner/work/dagu/dagu/internal/cmd/enqueue.go:61 +0x2f2
github.com/dagucloud/dagu/internal/cmd.NewCommand.func1(0x158559210c08, {0x876dd80, 0x0, 0x0})
        /home/runner/work/dagu/dagu/internal/cmd/context.go:879 +0x32e
github.com/spf13/cobra.(*Command).execute(0x158559210c08, {0x876dd80, 0x0, 0x0})
        /home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:1015 +0xb14
github.com/spf13/cobra.(*Command).ExecuteC(0x86f5be0)
        /home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:1148 +0x465
github.com/spf13/cobra.(*Command).Execute(...)
        /home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:1071
main.main()
        /home/runner/work/dagu/dagu/cmd/main.go:28 +0x1a

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions