From 7d8fa9609b0360820760a4ea0b8f468edbaa4f82 Mon Sep 17 00:00:00 2001 From: Dan Kortschak Date: Wed, 31 May 2023 08:55:27 +0930 Subject: [PATCH] internal/testrunner/runners/pipeline: clarify warning of error.message type 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. --- internal/testrunner/runners/pipeline/runner.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/internal/testrunner/runners/pipeline/runner.go b/internal/testrunner/runners/pipeline/runner.go index afdf5c1ff..8c97da3d3 100644 --- a/internal/testrunner/runners/pipeline/runner.go +++ b/internal/testrunner/runners/pipeline/runner.go @@ -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) }