From 4b8754188c56d4595bfce6bf54e15b72c39fcc66 Mon Sep 17 00:00:00 2001 From: "kushal (she/her)" <125429069+kbeniwal@users.noreply.github.com> Date: Thu, 23 Mar 2023 12:32:01 +0530 Subject: [PATCH] fix: nil pointer exception when account not found (#69) Signed-off-by: Kushal Beniwal Co-authored-by: Parikshit Samant <99033865+pns-nirmata@users.noreply.github.com> --- 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"