diff --git a/auth0/resource_auth0_user.go b/auth0/resource_auth0_user.go index ae85ea726..42eeb562b 100644 --- a/auth0/resource_auth0_user.go +++ b/auth0/resource_auth0_user.go @@ -145,15 +145,21 @@ func readUser(ctx context.Context, d *schema.ResourceData, m interface{}) diag.D d.Set("picture", user.Picture), ) - userMeta, err := structure.FlattenJsonToString(user.UserMetadata) - if err != nil { - return diag.FromErr(err) + var userMeta string + if user.UserMetadata != nil { + userMeta, err = structure.FlattenJsonToString(*user.UserMetadata) + if err != nil { + return diag.FromErr(err) + } } result = multierror.Append(result, d.Set("user_metadata", userMeta)) - appMeta, err := structure.FlattenJsonToString(user.AppMetadata) - if err != nil { - return diag.FromErr(err) + var appMeta string + if user.AppMetadata != nil { + appMeta, err = structure.FlattenJsonToString(*user.AppMetadata) + if err != nil { + return diag.FromErr(err) + } } result = multierror.Append(result, d.Set("app_metadata", appMeta)) @@ -255,16 +261,17 @@ func buildUser(d *schema.ResourceData) (*management.User, error) { Blocked: Bool(d, "blocked"), } - var err error - user.UserMetadata, err = JSON(d, "user_metadata") + userMeta, err := JSON(d, "user_metadata") if err != nil { return nil, err } + user.UserMetadata = &userMeta - user.AppMetadata, err = JSON(d, "app_metadata") + appMeta, err := JSON(d, "app_metadata") if err != nil { return nil, err } + user.AppMetadata = &appMeta return user, nil } diff --git a/go.mod b/go.mod index c60f5a3bd..9a13eb914 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/auth0/terraform-provider-auth0 go 1.18 require ( - github.com/auth0/go-auth0 v0.9.1 + github.com/auth0/go-auth0 v0.9.2 github.com/dnaeon/go-vcr/v2 v2.0.1 github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 github.com/hashicorp/go-multierror v1.1.1 diff --git a/go.sum b/go.sum index ee13c08c4..787d39666 100644 --- a/go.sum +++ b/go.sum @@ -52,8 +52,8 @@ github.com/apparentlymart/go-textseg/v12 v12.0.0/go.mod h1:S/4uRK2UtaQttw1GenVJE github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw= github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= -github.com/auth0/go-auth0 v0.9.1 h1:sc9w+Znl53KXdgYFCLbFz93mW9aJlNK49u/KBsfbmUc= -github.com/auth0/go-auth0 v0.9.1/go.mod h1:kxxGNgF592VPvWSNPVWNbmWHs+R9c0MZCTuW+T3NgZw= +github.com/auth0/go-auth0 v0.9.2 h1:HKG2fchD92qSOOgjg4SDkvUMgUzXHoqcOON5Qfuo1QY= +github.com/auth0/go-auth0 v0.9.2/go.mod h1:kxxGNgF592VPvWSNPVWNbmWHs+R9c0MZCTuW+T3NgZw= github.com/aybabtme/iocontrol v0.0.0-20150809002002-ad15bcfc95a0 h1:0NmehRCgyk5rljDQLKUO+cRJCnduDyn11+zGZIc9Z48= github.com/aybabtme/iocontrol v0.0.0-20150809002002-ad15bcfc95a0/go.mod h1:6L7zgvqo0idzI7IO8de6ZC051AfXb5ipkIJ7bIA2tGA= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=