Duplicate Set Element with protected_tags resource when importing resource
Bug Report
I got this error from the provider when trying to import & update an existing protected_tag
╷
│ Error: Duplicate Set Element
│
│ This attribute contains duplicate values of:
│ tftypes.Object["access_level":tftypes.String,
│ "access_level_description":tftypes.String, "group_id":tftypes.Number,
│ "user_id":tftypes.Number]<"access_level":tftypes.String<"maintainer">,
│ "access_level_description":tftypes.String<"Lionel User">,
│ "group_id":tftypes.Number<null>, "user_id":tftypes.Number<"1">>
╵
The Gitlab API returned this:
[
{
"name": "*",
"create_access_levels": [
{
"id": 1,
"access_level": 40,
"access_level_description": "User",
"deploy_key_id": null,
"user_id": 1,
"group_id": null
},
{
"id": 2,
"access_level": 40,
"access_level_description": "User",
"deploy_key_id": null,
"user_id": 1,
"group_id": null
}
]
}
]
Relevant Terraform Configuration
When creating a project from a template, when the tag_protection already contains some access_tokens, the users will be replaced with the user doing the import, creating duplicate entries in the protected_tags API.
Can be reproduced with an API call to create a new tag protection, with the same user/group referenced at least twice.
Then use the resource gitlab_tag_protection
to update it, along with the block import.
Relevant Terraform Command
terraform plan
Relevant Log Output
2024-12-12T15:28:00.235Z [ERROR] provider.terraform-provider-gitlab_v17.6.1: Response contains error diagnostic: diagnostic_severity=ERROR tf_rpc=ReadResource diagnostic_detail="This attribute contains duplicate values of: tftypes.Object[\"access_level\":tftypes.String, \"access_level_description\":tftypes.String, \"group_id\":tftypes.Number, \"user_id\":tftypes.Number]<\"access_level\":tftypes.String<\"maintainer\">, \"access_level_description\":tftypes.String<\"User\">, \"group_id\":tftypes.Number<null>, \"user_id\":tftypes.Number<\"1\">>" diagnostic_summary="Duplicate Set Element" tf_proto_version=6.7 tf_resource_type=gitlab_tag_protection @module=sdk.proto diagnostic_attribute="AttributeName(\"allowed_to_create\")" tf_req_id=f40dfdb6-d9cf-9269-fab0-6581d2b09753 @caller=github.com/hashicorp/terraform-plugin-go@v0.25.0/tfprotov6/internal/diag/diagnostics.go:58 tf_provider_addr=registry.terraform.io/gitlabhq/gitlab timestamp=2024-12-12T15:28:00.235Z
2024-12-12T15:28:00.236Z [ERROR] vertex "module.tag_protection.gitlab_tag_protection.main[\"xxx:*\"]" error: Duplicate Set Element
Edited by Nicolas Boussuge