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

Prevent using user name with bitbucket_repository_user_permission. Must be UUID. #209

Conversation

barrywhart
Copy link

@barrywhart barrywhart commented May 18, 2024

This fixes a nuisance issue I noticed. With bitbucket_repository_user_permission, if user_id is a user name (rather than a UUID), the changes apply without error, but subsequent runs of terraform plan and terraform apply always show a change needs to be applied.

I noticed that the provider documentation explicitly states that user_id is "The UUID of the user.", so it seems best to disallow the use of user names. This PR does that. As a bonus, the error message provides the UUID of the user to make it easy to fix the code.

  user_permissions = {
    "my-user-name" = "write",
    # Should be a UUID
  "{aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa}" = "write",
  }

@@ -105,6 +105,10 @@ func resourceRepositoryUserPermissionPut(ctx context.Context, d *schema.Resource
d.SetId(fmt.Sprintf("%s:%s:%s", workspace, repoSlug, userSlug))
}

if userSlug != permission.User.UUID {
return diag.FromErr(fmt.Errorf("The user_id must be a UUID, but a user name was given (\"%s\"). The UUID for this user is \"%s\".", userSlug, permission.User.UUID))
Copy link
Author

Choose a reason for hiding this comment

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

For convenience, the error message includes the UUID of the user, to make it easy to update the incorrect user_id.

Copy link
Owner

@DrFaust92 DrFaust92 left a comment

Choose a reason for hiding this comment

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

LGTM

@DrFaust92 DrFaust92 merged commit bb787af into DrFaust92:master May 30, 2024
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