Skip to content

Commit e37f454

Browse files
authored
internal/testrunner/runners/pipeline: clarify warning of error.message type (#1286)
The current warning is unclear and confusing when a []any containing only strings is held in error.message. encoding/json will store an array of string as []any, so when we see that check each element for stringness.
1 parent f8b3c8c commit e37f454

File tree

1 file changed

+10
-0
lines changed
  • internal/testrunner/runners/pipeline

1 file changed

+10
-0
lines changed

internal/testrunner/runners/pipeline/runner.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,16 @@ func checkErrorMessage(event json.RawMessage) error {
385385
return nil
386386
case string, []string:
387387
return fmt.Errorf("unexpected pipeline error: %s", m)
388+
case []interface{}:
389+
for i, v := range m {
390+
switch v.(type) {
391+
case string:
392+
break
393+
default:
394+
return fmt.Errorf("unexpected pipeline error (unexpected error.message type %T at position %d): %v", v, i, m)
395+
}
396+
}
397+
return fmt.Errorf("unexpected pipeline error: %s", m)
388398
default:
389399
return fmt.Errorf("unexpected pipeline error (unexpected error.message type %T): %[1]v", m)
390400
}

0 commit comments

Comments
 (0)