Skip to content

Commit dcdc683

Browse files
authored
fix(api): scan error on stopRunsBlocked (#5031)
stacktrace was: ``` workflow.stopRunsBlocked> Error on stopRunsBlocked : GoRoutine>Serve>Initialize> stopRunsBlocked: internal server error (caused by: cannot get workflow node run infos: sql: Scan error on column index 2, name "stages": converting NULL to string is unsupported) ```
1 parent 449ef4d commit dcdc683

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

engine/api/workflow/dao_run.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -998,9 +998,9 @@ func stopRunsBlocked(ctx context.Context, db *gorp.DbMap) error {
998998
}
999999

10001000
resp := []struct {
1001-
ID int64 `db:"id"`
1002-
Status string `db:"status"`
1003-
Stages string `db:"stages"`
1001+
ID int64 `db:"id"`
1002+
Status string `db:"status"`
1003+
Stages sql.NullString `db:"stages"`
10041004
}{}
10051005

10061006
querySelectNodeRuns := `
@@ -1018,8 +1018,10 @@ func stopRunsBlocked(ctx context.Context, db *gorp.DbMap) error {
10181018
ID: resp[i].ID,
10191019
Status: resp[i].Status,
10201020
}
1021-
if err := json.Unmarshal([]byte(resp[i].Stages), &nr.Stages); err != nil {
1022-
return sdk.WrapError(err, "cannot unmarshal stages")
1021+
if resp[i].Stages.Valid {
1022+
if err := json.Unmarshal([]byte(resp[i].Stages.String), &nr.Stages); err != nil {
1023+
return sdk.WrapError(err, "cannot unmarshal stages")
1024+
}
10231025
}
10241026

10251027
stopWorkflowNodeRunStages(ctx, db, &nr)

0 commit comments

Comments
 (0)