From 949b67bec60e750ad1d6f5c36bd1268a85ea8811 Mon Sep 17 00:00:00 2001 From: "A.Unger" Date: Fri, 31 Jan 2020 14:41:29 +0100 Subject: [PATCH] defensive coce --- pkg/service/v0/service.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/service/v0/service.go b/pkg/service/v0/service.go index 11b5403e8..e15c5e11a 100644 --- a/pkg/service/v0/service.go +++ b/pkg/service/v0/service.go @@ -42,9 +42,11 @@ func (s Service) Get(c context.Context, req *proto.Query, res *proto.Record) err // TODO deal with this } - r := &proto.Payload{} - json.Unmarshal(contents[0].Value, r) + if len(contents) > 0 { + r := &proto.Payload{} + json.Unmarshal(contents[0].Value, r) + res.Payload = r + } - res.Payload = r return nil }