Skip to content

Commit e97e232

Browse files
committed
fix potential bug
Signed-off-by: yuteng <a08h0283@gmail.com>
1 parent 77d4ce8 commit e97e232

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

runs/service/run_service.go

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,25 +1069,34 @@ func actionModelToClusterEvents(action *models.Action) []*workflow.ClusterEvent
10691069

10701070
// runModelToDetails converts a DB Run model to a RunDetails proto.
10711071
func (s *RunService) runModelToDetails(run *models.Run, runID *common.RunIdentifier) *workflow.RunDetails {
1072+
if run == nil && runID == nil {
1073+
return nil
1074+
}
10721075
var runSpec *task.RunSpec
1073-
if len(run.ActionSpec) > 0 {
1076+
if run != nil && len(run.ActionSpec) > 0 {
10741077
var actionSpec workflow.ActionSpec
10751078
if err := json.Unmarshal(run.ActionSpec, &actionSpec); err == nil {
10761079
runSpec = actionSpec.RunSpec
10771080
}
10781081
}
10791082

1083+
id := &common.ActionIdentifier{
1084+
Run: runID,
1085+
}
1086+
if run != nil {
1087+
id.Name = run.Name
1088+
}
10801089
return &workflow.RunDetails{
10811090
RunSpec: runSpec,
1082-
Action: s.actionModelToDetails(run, &common.ActionIdentifier{
1083-
Run: runID,
1084-
Name: run.Name,
1085-
}),
1091+
Action: s.actionModelToDetails(run, id),
10861092
}
10871093
}
10881094

10891095
// actionModelToDetails converts a DB Action model to an ActionDetails proto.
10901096
func (s *RunService) actionModelToDetails(action *models.Action, actionID *common.ActionIdentifier) *workflow.ActionDetails {
1097+
if action == nil && actionID == nil {
1098+
return nil
1099+
}
10911100
details := &workflow.ActionDetails{
10921101
Id: actionID,
10931102
}

0 commit comments

Comments
 (0)