From 67003ed469a5157c3d0a53f8419d5016c9089b50 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Tue, 10 Jun 2025 23:39:35 -0400 Subject: [PATCH] fix: skip cron entries that are missing a command or a schedule --- plugins/cron/cron.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/plugins/cron/cron.go b/plugins/cron/cron.go index dd30c25e8..667f5ecf7 100644 --- a/plugins/cron/cron.go +++ b/plugins/cron/cron.go @@ -4,6 +4,7 @@ import ( "fmt" appjson "github.com/dokku/dokku/plugins/app-json" + "github.com/dokku/dokku/plugins/common" "github.com/multiformats/go-base36" cronparser "github.com/robfig/cron/v3" @@ -75,7 +76,17 @@ func FetchCronEntries(appName string) ([]TemplateCommand, error) { return commands, nil } - for _, c := range appJSON.Cron { + for i, c := range appJSON.Cron { + if c.Command == "" { + common.LogWarn(fmt.Sprintf("Missing cron command for app %s (index %d)", appName, i)) + continue + } + + if c.Schedule == "" { + common.LogWarn(fmt.Sprintf("Missing cron schedule for app %s (index %d)", appName, i)) + continue + } + parser := cronparser.NewParser(cronparser.Minute | cronparser.Hour | cronparser.Dom | cronparser.Month | cronparser.Dow | cronparser.Descriptor) _, err := parser.Parse(c.Schedule) if err != nil {