Skip to content

Commit e08abe6

Browse files
committed
fix: adding nil check for job spec retry behaviour
1 parent 16d79f1 commit e08abe6

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

api/handler/v1/adapter.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,14 @@ func (adapt *Adapter) FromJobProto(spec *pb.JobSpecification) (models.JobSpec, e
7171
}
7272

7373
retryDelay := time.Duration(0)
74-
if spec.Behavior != nil && spec.Behavior.Retry.Delay != nil && spec.Behavior.Retry.Delay.IsValid() {
75-
retryDelay = spec.Behavior.Retry.Delay.AsDuration()
74+
retryCount := 0
75+
retryExponentialBackoff := false
76+
if spec.Behavior != nil && spec.Behavior.Retry != nil {
77+
retryCount = int(spec.Behavior.Retry.Count)
78+
retryExponentialBackoff = spec.Behavior.Retry.ExponentialBackoff
79+
if spec.Behavior.Retry.Delay != nil && spec.Behavior.Retry.Delay.IsValid() {
80+
retryDelay = spec.Behavior.Retry.Delay.AsDuration()
81+
}
7682
}
7783
return models.JobSpec{
7884
Version: int(spec.Version),
@@ -90,9 +96,9 @@ func (adapt *Adapter) FromJobProto(spec *pb.JobSpecification) (models.JobSpec, e
9096
DependsOnPast: spec.DependsOnPast,
9197
CatchUp: spec.CatchUp,
9298
Retry: models.JobSpecBehaviorRetry{
93-
Count: int(spec.Behavior.Retry.Count),
99+
Count: retryCount,
94100
Delay: retryDelay,
95-
ExponentialBackoff: spec.Behavior.Retry.ExponentialBackoff,
101+
ExponentialBackoff: retryExponentialBackoff,
96102
},
97103
},
98104
Task: models.JobSpecTask{

0 commit comments

Comments
 (0)