From e8d946493846996ed9d84070d7c8abbef639bce0 Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Sat, 7 Dec 2024 00:21:58 -0300 Subject: [PATCH] fix parsing COUNT envelopes without "hll". --- envelopes.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/envelopes.go b/envelopes.go index 5fcb78b..f197fb2 100644 --- a/envelopes.go +++ b/envelopes.go @@ -166,7 +166,12 @@ func (v *CountEnvelope) UnmarshalJSON(data []byte) error { } if err := json.Unmarshal([]byte(arr[2].Raw), &countResult); err == nil && countResult.Count != nil { v.Count = countResult.Count - v.HyperLogLog, _ = hex.DecodeString(countResult.HLL) + if len(countResult.HLL) == 512 { + v.HyperLogLog, err = hex.DecodeString(countResult.HLL) + if err != nil { + return fmt.Errorf("invalid \"hll\" value in COUNT message: %w", err) + } + } return nil }