From 64ad70130d9f56e1411bb8e4833979df2d511f96 Mon Sep 17 00:00:00 2001
From: elijahstorm <95153181+elijahstorm@users.noreply.github.com>
Date: Sun, 20 Oct 2024 12:27:17 +0900
Subject: [PATCH] add check for no bucket

---
 internal/localsvc/svc.go | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/internal/localsvc/svc.go b/internal/localsvc/svc.go
index 8b655eb5..478b73b2 100644
--- a/internal/localsvc/svc.go
+++ b/internal/localsvc/svc.go
@@ -155,6 +155,9 @@ func (svc *Service) SummarizeEvents(ctx context.Context, req *connect.Request[qr
 	if req.Msg.To == nil {
 		req.Msg.To = timestamppb.Now()
 	}
+	if req.Msg.BucketCount < 1 {
+		return nil, connect.NewError(connect.CodeInvalidArgument, fmt.Errorf("bucket count must be greater than 1"))
+	}
 	ll := svc.ll.With(
 		slog.Time("from", req.Msg.From.AsTime()),
 		slog.Time("to", req.Msg.From.AsTime()),