Skip to content

Commit

Permalink
internal/testrunner/runners/pipeline: clarify warning of error.messag…
Browse files Browse the repository at this point in the history
…e 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.
  • Loading branch information
efd6 authored Jun 1, 2023
1 parent f8b3c8c commit e37f454
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions internal/testrunner/runners/pipeline/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,16 @@ func checkErrorMessage(event json.RawMessage) error {
return nil
case string, []string:
return fmt.Errorf("unexpected pipeline error: %s", m)
case []interface{}:
for i, v := range m {
switch v.(type) {
case string:
break
default:
return fmt.Errorf("unexpected pipeline error (unexpected error.message type %T at position %d): %v", v, i, m)
}
}
return fmt.Errorf("unexpected pipeline error: %s", m)
default:
return fmt.Errorf("unexpected pipeline error (unexpected error.message type %T): %[1]v", m)
}
Expand Down

0 comments on commit e37f454

Please sign in to comment.