From ee9a355613ddfbebf48609e853aeaad698d6a293 Mon Sep 17 00:00:00 2001 From: Eli Ribble Date: Tue, 21 Apr 2026 21:55:48 +0000 Subject: [PATCH] Serialize nil slices as empty slices --- api/handler.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/api/handler.go b/api/handler.go index 88e5506a..a146f93d 100644 --- a/api/handler.go +++ b/api/handler.go @@ -115,7 +115,11 @@ func authenticatedHandlerJSONSlice[T any](f handlerFunctionGetSliceAuthenticated respondErrorStatus(w, e) return } - body, err = json.Marshal(resp) + if resp == nil { + body, err = json.Marshal([]struct{}{}) + } else { + body, err = json.Marshal(resp) + } if err != nil { respondErrorStatus(w, nhttp.NewError("failed to marshal json: %w", err)) return