Skip to content

diff.GetOk return nil for the value of TypeList defined in TypeSet #1197

@ms-zhenhua

Description

@ms-zhenhua

SDK version

v2.26.1

Relevant provider source code

{
Schema: map[string]*pluginsdk.Schema{
...
    "prop_set": {
	    Type:     pluginsdk.TypeSet,
	    Elem: &pluginsdk.Resource{
		    Schema: map[string]*pluginsdk.Schema{
			    ...
    
			    "prop_list": {
				    Type:     pluginsdk.TypeList,
				    Elem: &pluginsdk.Schema{
					    Type: pluginsdk.TypeString,
				    },
			    },
		    },
	    },
    },
...
},

...

CustomizeDiff: pluginsdk.CustomizeDiffShim(func(ctx context.Context, diff *pluginsdk.ResourceDiff, v interface{}) error {
...
    value, _ := diff.GetOk("prop_set")
...
}

...
}

Terraform Configuration Files

prop_set {
    ...
    prop_list = ["element-1"]
   ...
  }

Debug Output

Expected Behavior

diff.GetOk should return a prop_list with length=1 and the value is element-1

Actual Behavior

diff.GetOk should return a prop_list with length=1 and the value is nil

Steps to Reproduce

1. `terraform init`
2. `terraform apply`

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions