Skip to content

Commit b1b61a3

Browse files
tphoneyactions-user
authored andcommitted
fix, cli get change handles empty risks (#1398)
fixes [#1395](https://github.com/overmindtech/workspace/issues/1395) GitOrigin-RevId: dbcb1aff843efd323233e01e19861ef28000f73f
1 parent b5247cd commit b1b61a3

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

cmd/changes_get_change.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,15 +159,29 @@ fetch:
159159
break
160160
}
161161
}
162-
if calculateRiskStep == nil || calculateRiskStep.GetCalculatedRisks() == nil {
162+
lf["ovm.calculate.risk.step"] = fmt.Sprintf("%#v", calculateRiskStep)
163+
if calculateRiskStep == nil {
163164
return loggedError{
164165
err: fmt.Errorf("failed to find risk calculation step"),
165166
fields: lf,
166167
message: "failed to find risk calculation step",
167168
}
168169
}
170+
// calculatedRisks is set to []*sdp.Risk{} if the calculation step is done, but has no risks
171+
calculatedRisks := []*sdp.Risk{}
172+
if calculateRiskStep.GetCalculatedRisks() != nil {
173+
if calculateRiskStep.GetStatus() != sdp.ChangeTimelineEntryStatus_DONE {
174+
// error if we have some other status
175+
return loggedError{
176+
err: fmt.Errorf("risk calculation step is not done"),
177+
fields: lf,
178+
message: "risk calculation step is not done",
179+
}
180+
}
181+
calculatedRisks = calculateRiskStep.GetCalculatedRisks().GetRisks()
182+
}
183+
169184
// filter the risks
170-
calculatedRisks := calculateRiskStep.GetCalculatedRisks().GetRisks()
171185
if len(riskLevels) != 3 {
172186
log.WithContext(ctx).WithFields(log.Fields{
173187
"risk-levels": renderRiskFilter(riskLevels),

0 commit comments

Comments
 (0)