From 544096526070c5fcdbc5216b3a1262c94d832d4f Mon Sep 17 00:00:00 2001 From: Tristan Pemble Date: Wed, 1 Feb 2023 13:01:28 -0800 Subject: [PATCH] fix(#13844): canonicalize job to avoid nil pointer deference (#13845) --- .changelog/13845.txt | 3 +++ api/jobs.go | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 .changelog/13845.txt diff --git a/.changelog/13845.txt b/.changelog/13845.txt new file mode 100644 index 000000000..88778bcc8 --- /dev/null +++ b/.changelog/13845.txt @@ -0,0 +1,3 @@ +```release-note:bug +api: Fixed a nil pointer dereference when periodic jobs are missing their periodic spec +``` diff --git a/api/jobs.go b/api/jobs.go index a90111897..c9921c9fd 100644 --- a/api/jobs.go +++ b/api/jobs.go @@ -822,7 +822,7 @@ func (p *PeriodicConfig) Canonicalize() { // returned. The `time.Location` of the returned value matches that of the // passed time. func (p *PeriodicConfig) Next(fromTime time.Time) (time.Time, error) { - if *p.SpecType == PeriodicSpecCron { + if p != nil && *p.SpecType == PeriodicSpecCron { e, err := cronexpr.Parse(*p.Spec) if err != nil { return time.Time{}, fmt.Errorf("failed parsing cron expression %q: %v", *p.Spec, err)