-
-
Notifications
You must be signed in to change notification settings - Fork 149
auth0_tenant - 400 Bad Request: Payload validation error: 'Too few properties defined (0), minimum 1' #185
Comments
Yeah I got the same issue. This happens when you make a change that removes elements that were already present and do not change any other attributes in the same apply. Unfortunately this is really hard to handle as the logic is not completely clear. Do you want to ignore the "change_password" and "error_page" attributes (as you have not specified them) or do you want to set the values of all the properties to empty string? If you want the former behavior (i.e. where you want terraform to not manage those elements and let the Auth0 Management console specify them), I would suggest adding the four fields you've removed to the "lifecycle" "ignore_changes" section as well. If you would actually like to set their values to empty string, keep the elements but set all of their properties to empty string. |
I've actually rethought my original statement and I actually think this is a bug. How the provider generally works, if a resource isn't being created, it won't send a key on an update unless that key itself has changed. Unfortunately auth0 assumes in some of these cases that not sending a key implies the key should be set to empty string. Additionally if you change one value inside one of the mentioned blocks, but not the other value, you can often set the others to empty string. The specific big culprits are the ones you mention (the custom html blocks in the auth0_tenant resource) and the "options" in the "auth0_connection" resource. I've also discovered that the new v4 merge introduced a host of defects with the auth0_connection changes that I'm working on fixing right now. All of them are related to this issue. |
Thanks for jumping in @yinzara. The analysis makes sense really as this seems to appear with the tenant resource a lot the last couple of days. v4 shouldn't have had a huge impact on tenant but it had unfortunately and at this point I'm not 100% sure why. To start with, I think we need some tests to verify the broken behaviour 🤔 |
@icadariu-talend just so I can understand the exact situation, did you include |
Honestly I think we may need to think about the whole "Only include a field if it's changed" paradigm across the whole repo. I'm finding a host of small defects all related to using that methodology generally that only happen when we have specific changes in state that include some fields and not others. I'm curious, in the "Update" functions, why do we only send fields that have changed? I don't see any drawback to just sending the entire entity as long as all our fields are mapped correctly (there are some issues with the Connection entity I know of already with the "options" of incorrectly mapped fields because of issues in upper/lower casing). The amount of tests we'd have to cover every possible original state and then change is very error prone. |
I think the reason we're not catching a lot of these bugs is one of two reasons.
Fields that the user has not specified we be calculated as part of the read/refresh operation. Fields that are specified will be updated in the state to match and terraform will consider the resource unchanged unless an actual change is made to the resource. |
I imported an existing tenant. Clearly, the parameters are not all optional as per the docs. |
Honestly it goes a while back so I don't remember the exact reason why we send patches only. Perhaps due to the API relying on PATCH operations as the main method to update a resource... As to why we only get fields if they have changed, surely it's something we can take a step back and verify. We can pick a resource and re-write it to contain the entire payload instead of just changes. I know certain things are read-only so we can't be sending those fields (e.g. connection strategy, id's etc) but we can account for that too. The helper methods which check for On the other hand, the author of the kubernetes provider has written https://github.com/radeksimko/terraform-gen which should help generate most of the work, leaving some final touches to the developer. |
|
I've also noticed(please let me know if I should open a new issue) on auth0_connection that regardless of what we change on resource "auth0_connection" "my_connection" {
name = "Example-Connection"
strategy = "auth0"
options {
password_policy = "excellent"
password_history {
enable = true
size = 3
}
brute_force_protection = "true"
enabled_database_customization = "true"
custom_scripts = {
get_user = <<EOF
function getByEmail (email, callback) {
return callback(new Error("Whoops!"))
}
EOF
}
configuration = {
foo = "bar"
bar = "baz"
}
}
} PS: This last issue was discovered on |
Yes I think that is a separate issue. |
Ok, opened #195 |
After playing around a little with trying to send all fields instead of those which have changed, I think I have an answer to this question. The Auth0 API only offers PATCH as a method to modify resources. With these semantics, the resource is not replaced, but modified in-place (only the fields that were set). Feel free to check the result of the prototype here: https://github.com/alexkappa/terraform-provider-auth0/pull/194/files . |
Community Note
Terraform Version
Auth0 Provider Version
Affected Resource(s)
Terraform Configuration Files
Debug Output
Panic Output
Expected Behavior
Actual Behavior
Steps to Reproduce
terraform apply
Important Factoids
References
The text was updated successfully, but these errors were encountered: