Skip to content

Commit

Permalink
fix(api): check for nil pointer while deserializing duration proto
Browse files Browse the repository at this point in the history
  • Loading branch information
kushsharma committed Jun 14, 2021
1 parent 042f44c commit 1111b1d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion api/handler/v1/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ func (adapt *Adapter) FromJobProto(spec *pb.JobSpecification) (models.JobSpec, e
})
}

retryDelay := time.Duration(0)
if spec.Behavior.Retry.Delay != nil && spec.Behavior.Retry.Delay.IsValid() {
retryDelay = spec.Behavior.Retry.Delay.AsDuration()
}
return models.JobSpec{
Version: int(spec.Version),
Name: spec.Name,
Expand All @@ -87,7 +91,7 @@ func (adapt *Adapter) FromJobProto(spec *pb.JobSpecification) (models.JobSpec, e
CatchUp: spec.CatchUp,
Retry: models.JobSpecBehaviorRetry{
Count: int(spec.Behavior.Retry.Count),
Delay: spec.Behavior.Retry.Delay.AsDuration(),
Delay: retryDelay,
ExponentialBackoff: spec.Behavior.Retry.ExponentialBackoff,
},
},
Expand Down

0 comments on commit 1111b1d

Please sign in to comment.