From a92da27427fe3c56847b1f4ce4da4a717831bb01 Mon Sep 17 00:00:00 2001 From: Mahe Tardy Date: Fri, 2 Feb 2024 12:24:42 +0100 Subject: [PATCH] pkg/sensors: fix a marshalling mistake on the error field Previously, we were using fmt.Sprint(err) that was printing on nil error, using err.Error() and setting the field only if the error is not nil is more appropriate. Signed-off-by: Mahe Tardy --- pkg/sensors/handler.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/sensors/handler.go b/pkg/sensors/handler.go index 9717a9c205e..0f94057f8a2 100644 --- a/pkg/sensors/handler.go +++ b/pkg/sensors/handler.go @@ -171,10 +171,13 @@ func (h *handler) listTracingPolicies(op *tracingPolicyList) error { Name: name, Enabled: col.state == EnabledState, FilterId: col.policyfilterID, - Error: fmt.Sprint(col.err), State: col.state.ToTetragonState(), } + if col.err != nil { + pol.Error = col.err.Error() + } + pol.Namespace = "" if tpNs, ok := col.tracingpolicy.(tracingpolicy.TracingPolicyNamespaced); ok { pol.Namespace = tpNs.TpNamespace()