Skip to content

Commit

Permalink
fix nil deference for all API callers
Browse files Browse the repository at this point in the history
  • Loading branch information
tgross committed Feb 1, 2023
1 parent d9633e5 commit 9a7c60e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .changelog/13845.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
api: Fixed a nil pointer dereference when periodic jobs are missing their periodic spec
```
2 changes: 1 addition & 1 deletion api/jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 0 additions & 3 deletions command/job_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,6 @@ func (c *JobRunCommand) Run(args []string) int {

evalID := resp.EvalID

// #13844: canonicalize the job in case it was a partial API definition
job.Canonicalize()

// Check if we should enter monitor mode
if detach || periodic || paramjob || multiregion {
c.Ui.Output("Job registration successful")
Expand Down

0 comments on commit 9a7c60e

Please sign in to comment.