Skip to content

Commit

Permalink
pkg/sensors: fix a marshalling mistake on the error field
Browse files Browse the repository at this point in the history
Previously, we were using fmt.Sprint(err) that was printing <nil> 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 <mahe.tardy@gmail.com>
  • Loading branch information
mtardy committed Feb 20, 2024
1 parent 90dfbd8 commit fd105d0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/sensors/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit fd105d0

Please sign in to comment.