From 7e0a20317316cafb87dc06b60d0c83b3cac80896 Mon Sep 17 00:00:00 2001 From: Vyr Cossont Date: Sun, 28 Jan 2024 02:49:04 -0800 Subject: [PATCH] [bugfix] Fix EmptyJSONObject/EmptyJSONArray (#2576) * Fix EmptyJSONObject/EmptyJSONArray These are meant to be the bytes representing an empty object and array in JSON: `{}` and `[]`. They are actually the strings `"{}"` and `"[]"`. This causes clients expecting an object or array to not be able to parse the response. * Use json.RawMessage instead of []byte --- internal/api/util/response.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/api/util/response.go b/internal/api/util/response.go index 753eaefb8..afdc578aa 100644 --- a/internal/api/util/response.go +++ b/internal/api/util/response.go @@ -51,8 +51,8 @@ var ( ErrorRateLimited = mustJSON(map[string]string{ "error": "rate limit reached", }) - EmptyJSONObject = mustJSON("{}") - EmptyJSONArray = mustJSON("[]") + EmptyJSONObject = json.RawMessage(`{}`) + EmptyJSONArray = json.RawMessage(`[]`) // write buffer pool. bufPool sync.Pool