fix(scripts): handle ignored enc.Encode error in telemetry server (#22855)

Check the `json.Encoder.Encode` error and print to stderr.

Part of the effort to enable `errcheck.check-blank` in golangci-lint.
This commit is contained in:
Mathias Fredriksson
2026-03-09 19:03:06 +02:00
committed by GitHub
parent e6983648aa
commit 9e7125f852
+3 -1
View File
@@ -43,7 +43,9 @@ func main() {
"version": r.Header.Get("X-Telemetry-Version"), "version": r.Header.Get("X-Telemetry-Version"),
"data": json.RawMessage(body), "data": json.RawMessage(body),
} }
_ = enc.Encode(output) if err := enc.Encode(output); err != nil {
_, _ = fmt.Fprintf(os.Stderr, "Error encoding telemetry output: %v\n", err)
}
w.WriteHeader(http.StatusAccepted) w.WriteHeader(http.StatusAccepted)
} }