Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libs/go/zmscli: fix dropped errors #2301

Merged
merged 1 commit into from
Sep 5, 2023
Merged

Conversation

alrs
Copy link
Contributor

@alrs alrs commented Sep 5, 2023

This fixes three dropped err variables in the libs/go/zmscli package.

@@ -166,6 +166,9 @@ func (cli Zms) importRoles(dn string, lstRoles []*zms.Role, existingRoles *zms.R
}
}
_, err = cli.AddRoleMembers(dn, rn, roleMembers)
if err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this check here is not correct. we already handle the error on line 185 where we check if we should report errors or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This error is unhandled, as a new err is created inside the if block on 152 when := is used.

adminRole, err := cli.Zms.GetRole(zms.DomainName(dn), "admin", nil, nil, nil)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The correct fix here would be to define adminRole as a local variable and replace := with just = so we don't create a new err variable and mask the one from outside the if block.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change made.

@@ -234,6 +237,9 @@ func (cli Zms) importRolesOld(dn string, lstRoles []interface{}, validatedAdmins
}
}
_, err = cli.AddRoleMembers(dn, rn, roleMembers)
if err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this check here is not correct. we already handle the error on line 253 where we check if we should report errors or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This err is declared inside the if block when := is used, and is lost before the check on 253.

role, err := cli.Zms.GetRole(zms.DomainName(dn), "admin", nil, nil, nil)

Signed-off-by: Lars Lehtonen <lars.lehtonen@gmail.com>
Copy link
Collaborator

@havetisyan havetisyan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@havetisyan havetisyan merged commit 175b268 into AthenZ:master Sep 5, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants