From 0eb721fff747bcc2e2720b0fd81fe896cca38d05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E6=99=BA=E8=B6=850668000959?= Date: Fri, 26 Jun 2026 22:57:48 +0800 Subject: [PATCH] fix(health): explicitly ignore json.Encode errors in HTTP handler responses --- pkg/health/server.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/health/server.go b/pkg/health/server.go index 22346490c..0f3275316 100644 --- a/pkg/health/server.go +++ b/pkg/health/server.go @@ -162,7 +162,7 @@ func (s *Server) reloadHandler(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json") w.WriteHeader(http.StatusOK) - json.NewEncoder(w).Encode(map[string]string{"status": "reload triggered"}) + _ = json.NewEncoder(w).Encode(map[string]string{"status": "reload triggered"}) } func (s *Server) healthHandler(w http.ResponseWriter, r *http.Request) { @@ -176,7 +176,7 @@ func (s *Server) healthHandler(w http.ResponseWriter, r *http.Request) { PID: os.Getpid(), } - json.NewEncoder(w).Encode(resp) + _ = json.NewEncoder(w).Encode(resp) } func (s *Server) readyHandler(w http.ResponseWriter, r *http.Request) { @@ -190,7 +190,7 @@ func (s *Server) readyHandler(w http.ResponseWriter, r *http.Request) { if !ready { w.WriteHeader(http.StatusServiceUnavailable) - json.NewEncoder(w).Encode(StatusResponse{ + _ = json.NewEncoder(w).Encode(StatusResponse{ Status: "not ready", Checks: checks, }) @@ -200,7 +200,7 @@ func (s *Server) readyHandler(w http.ResponseWriter, r *http.Request) { for _, check := range checks { if check.Status == "fail" { w.WriteHeader(http.StatusServiceUnavailable) - json.NewEncoder(w).Encode(StatusResponse{ + _ = json.NewEncoder(w).Encode(StatusResponse{ Status: "not ready", Checks: checks, }) @@ -210,7 +210,7 @@ func (s *Server) readyHandler(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) uptime := time.Since(s.startTime) - json.NewEncoder(w).Encode(StatusResponse{ + _ = json.NewEncoder(w).Encode(StatusResponse{ Status: "ready", Uptime: uptime.String(), Checks: checks,