mhoppa commented on a change in pull request #4482: Rework 
cdns/name/:name/dnsseckeys/delete
URL: https://github.com/apache/trafficcontrol/pull/4482#discussion_r391078664
 
 

 ##########
 File path: traffic_ops/traffic_ops_golang/api/api.go
 ##########
 @@ -289,17 +289,24 @@ func WriteAlerts(w http.ResponseWriter, r *http.Request, 
code int, alerts tc.Ale
        }
        setRespWritten(r)
 
-       resp, err := json.Marshal(alerts)
-       if err != nil {
-               handleSimpleErr(w, r, http.StatusInternalServerError, nil, 
fmt.Errorf("marshalling JSON: %v", err))
-               return
-       }
        w.Header().Set(rfc.ContentType, rfc.ApplicationJSON)
        w.WriteHeader(code)
-       w.Write(append(resp, '\n'))
+       if alerts.HasAlerts() {
+               resp, err := json.Marshal(alerts)
+               if err != nil {
+                       handleSimpleErr(w, r, http.StatusInternalServerError, 
nil, fmt.Errorf("marshalling JSON: %v", err))
+                       return
+               }
+               _, _ = w.Write(append(resp, '\n'))
 
 Review comment:
   ?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to