karmada icon indicating copy to clipboard operation
karmada copied to clipboard

operator/pkg: mitigate null pointer dereference in `Validate()` and `newRunData()` functions

Open mohamedawnallah opened this issue 4 months ago • 1 comments

Description

In this commit, we mitigate the null pointer dereference issue in the deinit operator pkg by adding defensive checks on opt.Karmada.Spec.HostCluster in newRunData func and on opt.Karmada.Spec.Components in Validate in init.go.

Motivation and Context

While unit testing the Karmada Init and DeInit in the operator package (#5613), deliberately passing empty components on those fields triggers a null pointer exception error. This PR resolves this issue by adding defensive checks.

While testing

What type of PR is this?

/kind cleanup

Does this PR introduce a user-facing change?:

NONE

mohamedawnallah avatar Sep 27 '24 12:09 mohamedawnallah