From 79110c202bbd7172ff7bd10112c51629a1c60d04 Mon Sep 17 00:00:00 2001 From: Lauren Leach Date: Tue, 26 Nov 2024 11:47:33 -0800 Subject: [PATCH] invert resp nil logic --- pkg/connector/group.go | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/pkg/connector/group.go b/pkg/connector/group.go index cae39f88..b63cea47 100644 --- a/pkg/connector/group.go +++ b/pkg/connector/group.go @@ -175,27 +175,28 @@ func (o *groupResourceType) Grants( case resourceTypeRole.Id: roles, resp, err := listGroupAssignedRoles(ctx, o.connector.client, groupID, nil) if err != nil { - if resp != nil { - defer resp.Body.Close() - errOkta, err := getError(resp) + if resp == nil { + return nil, "", nil, fmt.Errorf("okta-connectorv2: failed to list group roles: %w", err) + } + + defer resp.Body.Close() + errOkta, err := getError(resp) + if err != nil { + return nil, "", nil, err + } + if errOkta.ErrorCode == AccessDeniedErrorCode { + err = bag.Next("") if err != nil { return nil, "", nil, err } - if errOkta.ErrorCode == AccessDeniedErrorCode { - err = bag.Next("") - if err != nil { - return nil, "", nil, err - } - pageToken, err := bag.Marshal() - if err != nil { - return nil, "", nil, err - } - return nil, pageToken, nil, nil - } else { - return nil, "", nil, fmt.Errorf("okta-connectorv2: failed to list group roles: %v", errOkta) + pageToken, err := bag.Marshal() + if err != nil { + return nil, "", nil, err } + return nil, pageToken, nil, nil + } else { + return nil, "", nil, fmt.Errorf("okta-connectorv2: failed to list group roles: %v", errOkta) } - return nil, "", nil, fmt.Errorf("okta-connectorv2: failed to list group roles: %w", err) } for _, role := range roles {