From cd377217c329ef0fc157c4076276d5fda1766492 Mon Sep 17 00:00:00 2001 From: Kushal Beniwal Date: Wed, 22 Mar 2023 19:16:08 +0530 Subject: [PATCH] fix: nil pointer exception when account not found Signed-off-by: Kushal Beniwal --- controllers/awsadapterconfig_controller.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/controllers/awsadapterconfig_controller.go b/controllers/awsadapterconfig_controller.go index 932ef0c..91364c0 100644 --- a/controllers/awsadapterconfig_controller.go +++ b/controllers/awsadapterconfig_controller.go @@ -125,9 +125,9 @@ func (r *AWSAdapterConfigReconciler) Reconcile(ctx context.Context, req ctrl.Req *callerIdentity.Account, }, }) - if err != nil || len(x.Accounts) == 0 { - if len(x.Accounts) == 0 { - err = fmt.Errorf("empty Accounts array") + if err != nil || x == nil || len(x.Accounts) == 0 { + if err == nil { + err = fmt.Errorf("no data found for the requested query, inspector2:BatchGetAccountStatus") } msg := "error occurred while fetching inspector data"