vmware / terraform-provider-wavefront

Terraform Wavefront provider
https://www.terraform.io/docs/providers/wavefront/
Mozilla Public License 2.0
8 stars 23 forks source link

Inconsistent handling of customer id in email addresses #99

Open thomas11 opened 2 years ago

thomas11 commented 2 years ago

Describe the bug

This recent change assumes that an ID for user foo@bar.com, of customer C, looks like foo+C@bar.com.

    emailChunks := strings.Split(*user.ID, fmt.Sprintf("+%s", user.Customer))
    email := fmt.Sprintf("%s%s", emailChunks[0], emailChunks[1])
    d.Set("email", email)

To derive the original email from that, the code blindly splits on "+C" and panics if that doesn't work, which happened for our acceptance test.

So I changed our test mail address from test+py@mycompany.io to test+${customerid}@mycompany.io.

Now we get further, but this results in an unexpected change: the Terraform provider extracts +${customerid} from the given email and saves it as test@mycompany.io, different from the original email address. This results in an unexpected update due to changed email. But I cannot give the mail as test@mycompany.io in the first place, because then the string-splitting code panics.

I think email and user id were mixed up in this change. The actual email cannot be expected to have "+customerid" in it.

Reproduction steps

  1. Create a new Wavefront user with email test@something.com
  2. Reading this user will panic at resource_user.go line 99
  3. Create a user with email test+customer@something.com
  4. Creation will succeed bit email will be read back as test@something.com

Expected behavior

Email and user id should be separate concepts.

Additional context

No response