chore(lint): enable errchkjson (#6486)

errchkjson flags json.Marshal/MarshalIndent/Encoder.Encode calls whose error is discarded.
Fixed all 27 sites by hand: errors are returned where the caller already returns one, logged
in HTTP handlers and string-returning helpers, and asserted in tests.
check-error-free-encoding stays off so every encode error is handled, even for safe types.
report-no-exported is on, to catch structs that would silently encode as {}.
This commit is contained in:
Deluan Quintão authored and GitHub committed 2026-11-16 23:18:26 -05:00
1 parent e9c0efa446
commit 986000db44
26 files changed
+134 -45

No files matched your search

+6 -2
View File
@@ -138,7 +138,9 @@ func (api *Router) updatePlugin(w http.ResponseWriter, r *http.Request) {
}
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusUnprocessableEntity)
_ = json.NewEncoder(w).Encode(errorResponse)
if err := json.NewEncoder(w).Encode(errorResponse); err != nil {
log.Error(ctx, "Error encoding enable plugin error response", "id", id, err)
}
return
}
} else {
@@ -186,7 +188,9 @@ func validateAndUpdateConfig(ctx context.Context, pm PluginManager, id, configJS
w.WriteHeader(http.StatusBadRequest)
// Try to return structured validation errors if available
response := map[string]any{"message": err.Error()}
_ = json.NewEncoder(w).Encode(response)
if encErr := json.NewEncoder(w).Encode(response); encErr != nil {
log.Error(ctx, "Error encoding config validation response", "id", id, encErr)
}
return err
}