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

Don't panic on missing role in consul_acl_role_policy_attachment #379

Merged
merged 1 commit into from
Nov 20, 2023

Conversation

remilapeyre
Copy link
Collaborator

@remilapeyre remilapeyre commented Nov 20, 2023

resourceConsulACLRolePolicyAttachmentCreate() and resourceConsulACLRolePolicyAttachmentDelete()
were not checking properly if the given role ID was not found in Consul.

Some functions in the Consul SDK return an error when the object is missing,
other return a nil object.

In the case of RoleRead() I was checking for the wrong thing. I checked the
rest of the ACL resources and as far as I know it, this was the only
resource impacted.

I also update the consul_acl_policy data source to use the new
PolicyReadByName() function.

Closes #378

`resourceConsulACLRolePolicyAttachmentCreate()` and `resourceConsulACLRolePolicyAttachmentDelete()`
were not checking properly if the given role ID was not found in Consul.

Some functions in the Consul SDK return an error when the object is missing,
other return a `nil` object.

In the case of `RoleRead()` I was checking for the wrong thing. I checked the
rest of the ACL resources and as far as I know it, this was the only
resource impacted.

I also update the `consul_acl_policy` data source to use the new
`PolicyReadByName()` function.
@remilapeyre remilapeyre changed the title Don't panic on missing role in consul_cal_role_policy_attachment Don't panic on missing role in consul_acl_role_policy_attachment Nov 20, 2023
Comment on lines +59 to +61
if policy == nil {
return fmt.Errorf("could not find policy %q", name)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I just fixed the same bug in Consul CLI 😆
hashicorp/consul#19679

Copy link
Contributor

@dhiaayachi dhiaayachi left a comment

Choose a reason for hiding this comment

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

LGTM!

@remilapeyre remilapeyre merged commit 7b0c7aa into master Nov 20, 2023
4 checks passed
@remilapeyre remilapeyre deleted the issue-378 branch November 20, 2023 14:50
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.

consul_acl_role_policy_attachment causes unresponsive plugin in v2.19.0
2 participants