From 326c86f583b7bf88073c4e5a786262998657ab21 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Tue, 17 Nov 2020 10:14:43 +0200 Subject: [PATCH] Added ReplyError as nil in the response of the StringQuery if missing --- analyzers/analyzers.go | 3 +++ analyzers/analyzers_test.go | 1 + utils/consts.go | 1 + 3 files changed, 5 insertions(+) diff --git a/analyzers/analyzers.go b/analyzers/analyzers.go index a5d6b8a69..89255a0e0 100755 --- a/analyzers/analyzers.go +++ b/analyzers/analyzers.go @@ -162,6 +162,9 @@ func (aS *AnalyzerService) V1StringQuery(args *QueryArgs, reply *[]map[string]in if dur, err := utils.IfaceAsDuration(obj.Fields[utils.RequestDuration]); err == nil { obj.Fields[utils.RequestDuration] = dur.String() } + if val, has := obj.Fields[utils.ReplyError]; !has || len(utils.IfaceAsString(val)) == 0 { + obj.Fields[utils.ReplyError] = nil + } if lCntFltrs != 0 { repDP, err := unmarshalJSON(rep) if err != nil { diff --git a/analyzers/analyzers_test.go b/analyzers/analyzers_test.go index 1a4030dd8..8f9736fa2 100644 --- a/analyzers/analyzers_test.go +++ b/analyzers/analyzers_test.go @@ -278,6 +278,7 @@ func TestAnalyzersV1Search(t *testing.T) { "Reply": json.RawMessage(`"Pong"`), "RequestSource": "127.0.0.1:5566", "RequestStartTime": t1.Add(-24 * time.Hour).UTC().Format(time.RFC3339), + "ReplyError": nil, }} reply = []map[string]interface{}{} if err = anz.V1StringQuery(&QueryArgs{HeaderFilters: utils.RequestDuration + ":>=" + strconv.FormatInt(int64(time.Hour), 10)}, &reply); err != nil { diff --git a/utils/consts.go b/utils/consts.go index 026c0641d..23d16a02b 100755 --- a/utils/consts.go +++ b/utils/consts.go @@ -2515,6 +2515,7 @@ const ( RequestDuration = "RequestDuration" RequestParams = "RequestParams" Reply = "Reply" + ReplyError = "ReplyError" ) var (