-
Notifications
You must be signed in to change notification settings - Fork 301
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
azuread: GroupsClient.BaseClient.Post(): unexpected status 400 with OData error: Request_BadRequest: Request contains a property with duplicate values. #624
Comments
I updated the example code (most basic variant) and attached a gist. |
Hi @kyrios, thanks for raising this. We have seen this behavior intermittently before (see #478, #567) but we are still tracking this and raising with the service team as a breaking API change. It's possible this might be related to #588, but this error is not caused by it. At this time there's no viable workaround for us, as Terraform is, on balance, doing the right thing here. The API behavior seems to differ between some tenants and changing our payload for group creation to work around this would break more users in the process. Sorry that we can't resolve this right now, but as mentioned we are having conversations about this and we'll keep this issue updated as we learn more. Thanks! |
Hi @manicminer, let me verify that I understand you correctly: There is no workaroung using terraform (the Azure API) and no bugfix planned since the bug isn't understood yet by Microsoft. It is related to our tennant and there is nothing we can do about it. That indeed is very bad news. |
Unfortunately that is correct. We're hoping to get some traction on this very soon but right now Terraform cannot resolve this error. I'm afraid since this doesn't affect any of our testing tenants that our ability to experiment with this is limited, however you might try adding additional arbitrary owners to the group to see if this helps bypass this error. The error appears to stem from specifying the calling principal as the sole owner of the group. In many cases the API assigns that same principal as the default owner in the case that none are specified, but this doesn't appear to be universal, and the 'duplicate' error only seems to occur for a subset of users. |
Maybe as some additional information: It worked a week ago with version 2.4.0 |
As much as this may be related to the recent API changes, despite the coincidental timing this isn't a result of any change to Terraform :( |
I understand. Just wanted to add every last bit of information I have. |
I hit this with #567. My workaround is to assign someone other than myself as an |
@manicminer I actually just find a problem with my workaround. The next time I ran a |
That workaround seems to be working. Thanks a lot for sharing it @mlcooper! Here is the code we are using: owners = ["foo-bar-foo-1"]
lifecycle {
ignore_changes = [
# Ignore changes to tags, e.g. because a management agent
# updates these based on some ruleset managed elsewhere.
owners,
]
}
|
Is there any update on this issue? |
This issue is due to, and blocked by, an API bug which is reported at microsoftgraph/msgraph-metadata#92 |
I faced the same error and was able to "fix" it by assigning the authenticated user principal to the directory role |
In the enterprise I am working at, it is impossible for ordinary mortals to acquire such elevated rights. My workaround for daily use in Terraform is to create the group via Azure CLI and import it into the state for further management via Terraform, e.g. like this:
(It is only the creation of the group that fails. Further modifications are working.) |
I experienced this issue when I was authenticating using a service principal. After I gave the Group.ReadWrite.All API permission to the SPN it worked. This is also stated in the documentation:
I must admit it isn't the ideal solution to give such broad permissions. |
Verified Authz issue in my organization. |
I'm having a similar problem, but with the newer version mentioned in this issue: #789.
My problem was solved after refreshing my terminal session with new Azure login. |
Activating my Azure PIM roles fixed this for me. |
This fixed it for me, thank you. |
If anyone comes across this issue, this did it for me (little dirty but can live with that code until this is fixed) - locals {
azuread_admin_group_mail_nickname = uuidv5("dns", "ca.dev.xyz")
azuread_admin_group_owners = concat([data.azuread_service_principal.terraform_client.id], data.azuread_user.admin_user.*.id)
azuread_admin_group_id = shell_script.azuread_admin_group.output.id
}
provider "shell" {}
resource "shell_script" "azuread_admin_group" {
lifecycle_commands {
create = "az ad group create --display-name ${var.azuread_admin_group_name} --mail-nickname ${local.azuread_admin_group_mail_nickname}"
read = "az ad group show --group ${var.azuread_admin_group_name}"
update = "az ad group delete --group ${var.azuread_admin_group_name} && az ad group create --display-name ${var.azuread_admin_group_name} --mail-nickname ${local.azuread_admin_group_mail_nickname}"
delete = "az ad group delete --group ${var.azuread_admin_group_name}"
}
} |
Any news on this? |
Not really. To my understanding, the root cause microsoftgraph/msgraph-metadata#92 is still open. However, a colleague of mine and me did some more testing and we found out that you can actually create an AD group of type If you we use a service principal to authenticate (our The following code snippet illustrates our finding.
|
Hi all, since it seems there is no traction as yet with fixing this in the API, I am proposing a potential fix for this error by retrying the group creation when this error is detected and the calling principal has been specified as an owner. The workaround relies on the other side of this API bug, that the calling principal is auto-added behind the scenes and the group is subsequently returned having the calling principal as an auto-appended owner. If anyone is able to test out by compiling the provider locally from the |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Community Note
Terraform (and AzureAD Provider) Version
Terraform 1.0.2
Azuread 2.6.0
Affected Resource(s)
azuread_group
Terraform Configuration Files
Debug Output
https://gist.github.com/kyrios/142a0ba5350047f3ec9611ea8fe2a05d
Expected Behavior
No error
Actual Behavior
GroupsClient.BaseClient.Post(): unexpected status 400 with OData error: Request_BadRequest: Request contains a property with duplicate │ values.
Steps to Reproduce
terraform init
terraform apply
Important Factoids
We have been upgrading to 2.6.0 because of #588
References
#588
The text was updated successfully, but these errors were encountered: