fix(webui): return an interrupted stage's cause and show it in a warning tone

This commit is contained in:
sam committed 2026-10-19 02:05:45 +11:00
1 parent 25bd601a63
commit 4ce349cd15
4 files changed
+107 -82

No files matched your search

+2 -1
View File
@@ -297,7 +297,8 @@ func stageViewsFromSteps(steps []task.StepExecution, inFlight bool) []taskStageV
continue
}
view := taskStageView{ID: s.ID, Name: s.Name, Seq: len(stages), Status: mapStepStatus(s.Status, inFlight)}
if s.Status == taskstate.StepFailed {
// A skipped step's detail is its when condition, not a cause.
if s.Status == taskstate.StepFailed || s.Status == taskstate.StepInterrupted {
view.Error = s.Detail
}
if !s.StartedAt.IsZero() {
+19
View File
@@ -34,3 +34,22 @@ func TestEarlyAttemptHistory(t *testing.T) {
})
}
}
func TestStageErrorByStatus(t *testing.T) {
for _, tc := range []struct {
status taskstate.StepStatus
want string
}{
{taskstate.StepFailed, "boom"},
{taskstate.StepInterrupted, "boom"},
{taskstate.StepSkipped, ""},
{taskstate.StepSucceeded, ""},
} {
t.Run(string(tc.status), func(t *testing.T) {
steps := []task.StepExecution{{Kind: task.StepKindStage, Name: "build", Status: tc.status, Detail: "boom"}}
if got := stageViewsFromSteps(steps, false)[0].Error; got != tc.want {
t.Fatalf("error = %q, want %q", got, tc.want)
}
})
}
}