-
Notifications
You must be signed in to change notification settings - Fork 89
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
[2/2] #35 Fix infinite plan on user metadata #250
Conversation
|
||
for key := range oldMap { | ||
if _, ok := newMap[key]; !ok { | ||
newMap[key] = nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're applying the following explained logic in alexkappa/terraform-provider-auth0#392 (comment), where in order to properly remove something we need to send it's value as null.
This is because the metadata fields are merged instead of being replaced but the merge only occurs on the first level during a PATCH.
b94b80d
to
ab53fbc
Compare
Codecov Report
@@ Coverage Diff @@
## patch/fix-issue33-user_metadata #250 +/- ##
===================================================================
- Coverage 83.51% 83.48% -0.03%
===================================================================
Files 36 36
Lines 6835 6859 +24
===================================================================
+ Hits 5708 5726 +18
- Misses 898 902 +4
- Partials 229 231 +2
Continue to review full report at Codecov.
|
82d87a1
to
4de639b
Compare
6f2b50e
to
0723a22
Compare
} | ||
` | ||
|
||
func TestAccUserCanSerializeEmptyMetadataFields(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're removing this as we added it as a last test case for the TestAccUser scenario.
a5b254a
to
da76ed6
Compare
da76ed6
to
8f81eeb
Compare
Description
Fixes: #35
From: https://auth0.com/docs/api/management/v2#!/Users/patch_users_by_id
The API behaves in an unexpected way for the
user_metadata
andapp_metadata
where the values get merged instead of replaced but only on the first level. This means that if we want to completely remove a key from the object we need to send the key with a null value. We try to work around this and give a more predictable behavior for our terraform users by checking if the value was removed and if so, sending it as null so it also gets removed in the API call.Checklist
Note: Checklist required to be completed before a PR is considered to be reviewable.
Auth0 Code of Conduct
Auth0 General Contribution Guidelines
Changes include test coverage?
Does the description provide the correct amount of context?
Have you updated the documentation?
Is this code ready for production?