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

Resource commercetools_associate_role: order of permissions #505

Closed
md283aa opened this issue Jun 26, 2024 · 3 comments · Fixed by #510 or #551
Closed

Resource commercetools_associate_role: order of permissions #505

md283aa opened this issue Jun 26, 2024 · 3 comments · Fixed by #510 or #551
Labels
bug Something isn't working

Comments

@md283aa
Copy link

md283aa commented Jun 26, 2024

Version information

  • terraform: v1.8.5
  • terraform provider: 1.14.3

Describe the bug

When creating a commercetools_associate_role resource the array of permissions is not handled correctly. The permissions are obviously stored in a random order (or at least in a different order as the input array). When comparing the resource in commercetools with the tf spec it is always considered as different.

When applying the tf resource initially it returns:

commercetools_associate_role.my_role: Creating...
╷
│ Error: Provider produced inconsistent result after apply
│ 
│ When applying changes to commercetools_associate_role.my_role, provider "provider[\"registry.terraform.io/labd/commercetools\"]" produced an unexpected new value:
│ .permissions[0]: was cty.StringVal("CreateMyCarts"), but now cty.StringVal("ViewOthersCarts").
│ 
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.

To Reproduce

  • Create a commercetools_associate_role resource with a list of permissions
  • Apply the change
  • The above mentioned error is shown
  • Call a terraform plan without changing something
  • Terraform will detect a change within the order of the permissions
  • Take the list of permissions from the Commercetools API and replace it within the tf file
  • Call a terraform plan again
  • Terraform will not detect any changes

Expected behavior

Order of permissions is not taken into account when comparing permissions

Screenshots

If applicable, add screenshots to help explain your problem.

Additional context

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # commercetools_associate_role.my_role will be created
  + resource "commercetools_associate_role" "my_role" {
      + buyer_assignable = false
      + id               = (known after apply)
      + key              = "my_role"
      + name             = "My Role"
      + permissions      = [
          + "CreateMyCarts",
          + "DeleteMyCarts",
          + "UpdateMyCarts",
          + "ViewMyCarts",
          + "CreateMyOrdersFromMyCarts",
          + "CreateMyOrdersFromMyQuotes",
          + "UpdateMyOrders",
          + "ViewMyOrders",
          + "AcceptMyQuotes",
          + "ReassignMyQuotes",
          + "RenegotiateMyQuotes",
          + "ViewMyQuotes",
          + "CreateMyQuoteRequestsFromMyCarts",
          + "UpdateMyQuoteRequests",
          + "ViewMyQuoteRequests",
          + "ViewOthersQuotes",
          + "ViewOthersCarts",
          + "CreateOrdersFromOthersCarts",
          + "CreateOrdersFromOthersQuotes",
          + "UpdateOthersOrders",
          + "ViewOthersOrders",
          + "AcceptOthersQuotes",
          + "ReassignOthersQuotes",
          + "RenegotiateOthersQuotes",
          + "ViewOthersQuotes",
          + "CreateQuoteRequestsFromOthersCarts",
          + "UpdateOthersQuoteRequests",
          + "ViewOthersQuoteRequests",
        ]
      + version          = (known after apply)
    }

Plan: 1 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

commercetools_associate_role.my_role: Creating...
╷
│ Error: Provider produced inconsistent result after apply
│ 
│ When applying changes to commercetools_associate_role.my_role, provider "provider[\"registry.terraform.io/labd/commercetools\"]" produced an unexpected new value:
│ .permissions[0]: was cty.StringVal("CreateMyCarts"), but now cty.StringVal("ViewOthersCarts").
│ 
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.
╵
╷
│ Error: Provider produced inconsistent result after apply
│ 
│ When applying changes to commercetools_associate_role.my_role, provider "provider[\"registry.terraform.io/labd/commercetools\"]" produced an unexpected new value:
│ .permissions[1]: was cty.StringVal("DeleteMyCarts"), but now cty.StringVal("CreateQuoteRequestsFromOthersCarts").
│ 
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.
╵
╷
│ Error: Provider produced inconsistent result after apply
│ 
│ When applying changes to commercetools_associate_role.my_role, provider "provider[\"registry.terraform.io/labd/commercetools\"]" produced an unexpected new value:
│ .permissions[3]: was cty.StringVal("ViewMyCarts"), but now cty.StringVal("CreateMyOrdersFromMyCarts").
│ 
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.
╵
@md283aa md283aa added bug Something isn't working triage Needs triage labels Jun 26, 2024
@md283aa md283aa changed the title Resource commercetools_associate_role: permissions order Resource commercetools_associate_role: order of permissions Jun 26, 2024
@demeyerthom
Copy link
Member

Hi @md283aa yeah looks like we need to improve the slice ordering for the permissions. I will take a look at this as soon as I can find some time!

@demeyerthom demeyerthom removed the triage Needs triage label Jul 19, 2024
@demeyerthom demeyerthom linked a pull request Aug 23, 2024 that will close this issue
@md283aa
Copy link
Author

md283aa commented Nov 27, 2024

Is this bug really fixed. I have just tested it again and got the same error with TF version 1.7.5 and provider version 1.17.0

commercetools_associate_role.my_role: Creating...

│ Error: Provider produced inconsistent result after apply

│ When applying changes to commercetools_associate_role.my_role, provider
│ "provider["registry.terraform.io/labd/commercetools"]" produced an unexpected new value: .permissions[0]:
│ was cty.StringVal("CreateMyCarts"), but now cty.StringVal("ViewOthersCarts").

│ This is a bug in the provider, which should be reported in the provider's own issue tracker.

@gasttor
Copy link
Contributor

gasttor commented Dec 17, 2024

Hi @demeyerthom,

I had another look at this bug and I can still reproduce it. I already fixed this and could provide a PR for this. Should we reopen this ticket, or do I have to create a new one?

Regards

Thorsten

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
3 participants