fix(#13844): canonicalize job to avoid nil pointer deference (#13845)

This commit is contained in:
Tristan Pemble 2023-02-01 13:01:28 -08:00 committed by GitHub
parent ca7ead191e
commit 5440965260
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

3
.changelog/13845.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:bug
api: Fixed a nil pointer dereference when periodic jobs are missing their periodic spec
```

View File

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