Skip to content

Commit 1111b1d

Browse files
committed
fix(api): check for nil pointer while deserializing duration proto
1 parent 042f44c commit 1111b1d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

api/handler/v1/adapter.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ func (adapt *Adapter) FromJobProto(spec *pb.JobSpecification) (models.JobSpec, e
7070
})
7171
}
7272

73+
retryDelay := time.Duration(0)
74+
if spec.Behavior.Retry.Delay != nil && spec.Behavior.Retry.Delay.IsValid() {
75+
retryDelay = spec.Behavior.Retry.Delay.AsDuration()
76+
}
7377
return models.JobSpec{
7478
Version: int(spec.Version),
7579
Name: spec.Name,
@@ -87,7 +91,7 @@ func (adapt *Adapter) FromJobProto(spec *pb.JobSpecification) (models.JobSpec, e
8791
CatchUp: spec.CatchUp,
8892
Retry: models.JobSpecBehaviorRetry{
8993
Count: int(spec.Behavior.Retry.Count),
90-
Delay: spec.Behavior.Retry.Delay.AsDuration(),
94+
Delay: retryDelay,
9195
ExponentialBackoff: spec.Behavior.Retry.ExponentialBackoff,
9296
},
9397
},

0 commit comments

Comments
 (0)