From 0acc23ef6189d533390e24ed497a11afe58c5a67 Mon Sep 17 00:00:00 2001 From: Michael Mraka Date: Mon, 9 Sep 2024 14:59:09 +0200 Subject: [PATCH] RHINENG-9505: parse response only if not empty --- base/api/client.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/base/api/client.go b/base/api/client.go index 96f8d81a1..6bab2de53 100644 --- a/base/api/client.go +++ b/base/api/client.go @@ -44,9 +44,11 @@ func (o *Client) Request(ctx *context.Context, method, url string, return httpResp, errors.Wrap(err, "Response body reading failed") } - err = json.Unmarshal(bodyBytes, responseOutPtr) - if err != nil { - return httpResp, errors.Wrap(err, "Response json parsing failed") + if len(bodyBytes) > 0 { + err = json.Unmarshal(bodyBytes, responseOutPtr) + if err != nil { + return httpResp, errors.Wrap(err, "Response json parsing failed") + } } return httpResp, nil }