{"record":{"id":"d20b6bdd7a79f30d","repo":"hashicorp/terraform","slug":"s-s-nestingset-attributes-may-not-contain-attrib","errorCode":null,"errorMessage":"%s%s: NestingSet attributes may not contain attributes of cty.DynamicPseudoType","messagePattern":"(.+?)(.+?): NestingSet attributes may not contain attributes of cty\\.DynamicPseudoType","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/configs/configschema/internal_validate.go","lineNumber":180,"sourceCode":"\n\tif a.Type != cty.NilType {\n\t\tif a.NestedType != nil {\n\t\t\terr = errors.Join(fmt.Errorf(\"%s: Type and NestedType cannot both be set\", name))\n\t\t}\n\t}\n\n\tif a.NestedType != nil {\n\t\tswitch a.NestedType.Nesting {\n\t\tcase NestingSingle, NestingMap, NestingGroup:\n\t\t\t// no validations to perform\n\t\tcase NestingList, NestingSet:\n\t\t\tif a.NestedType.Nesting == NestingSet {\n\t\t\t\tety := a.ImpliedType()\n\t\t\t\tif ety.HasDynamicTypes() {\n\t\t\t\t\t// This is not permitted because the HCL (cty) set implementation\n\t\t\t\t\t// needs to know the exact type of set elements in order to\n\t\t\t\t\t// properly hash them, and so can't support mixed types.\n\t\t\t\t\terr = errors.Join(err, fmt.Errorf(\"%s%s: NestingSet attributes may not contain attributes of cty.DynamicPseudoType\", prefix, name))\n\t\t\t\t}\n\t\t\t\tif a.NestedType.ContainsWriteOnly() {\n\t\t\t\t\t// This is not permitted because any marks within sets will\n\t\t\t\t\t// be hoisted up the outer set value, so only the set itself\n\t\t\t\t\t// can be WriteOnly.\n\t\t\t\t\terr = errors.Join(err, fmt.Errorf(\"%s%s: NestingSet attributes may not contain WriteOnly attributes\", prefix, name))\n\t\t\t\t}\n\t\t\t}\n\t\tdefault:\n\t\t\terr = errors.Join(err, fmt.Errorf(\"%s%s: invalid nesting mode %s\", prefix, name, a.NestedType.Nesting))\n\t\t}\n\t\tfor name, attrS := range a.NestedType.Attributes {\n\t\t\tif attrS == nil {\n\t\t\t\terr = errors.Join(err, fmt.Errorf(\"%s%s: attribute schema is nil\", prefix, name))\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\terr = errors.Join(err, attrS.internalValidate(name, prefix))\n\t\t}","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/configs/configschema/internal_validate.go#L162-L198","documentation":"Raised when an Attribute whose NestedType uses NestingSet contains cty.DynamicPseudoType in its implied type. This is the attribute-level analogue of error 822: cty sets need a concrete hashable element type, so dynamic typing inside a set is unsupported. The validator at internal_validate.go:174-176 calls a.ImpliedType().HasDynamicTypes() and rejects the schema.","triggerScenarios":"An Attribute with NestedType.Nesting == NestingSet whose nested Attributes include one with Type=cty.DynamicPseudoType (or any descendant resolving to dynamic). The NestingSet branch at line 174 evaluates HasDynamicTypes() at line 176 and it returns true.","commonSituations":"Using a structural set attribute (NestedType+NestingSet) to model deduped arbitrary objects; converting a NestedType list to a set without removing a dynamic 'metadata' field; framework-generated schemas defaulting unknown subfields to dynamic.","solutions":["Switch NestedType.Nesting to NestingList if dynamic-typed elements are required.","Constrain the dynamic nested attribute to a concrete hashable type (e.g. cty.Map(cty.String)).","Model arbitrary key/value data as a map rather than a set of dynamic objects."],"exampleFix":"// before\n\"items\": {\n    Optional: true,\n    NestedType: &Object{\n        Nesting: NestingSet,\n        Attributes: map[string]*Attribute{\"data\": {Type: cty.DynamicPseudoType, Optional: true}},\n    },\n}\n\n// after\n\"items\": {\n    Optional: true,\n    NestedType: &Object{\n        Nesting: NestingList,\n        Attributes: map[string]*Attribute{\"data\": {Type: cty.DynamicPseudoType, Optional: true}},\n    },\n}","handlingStrategy":"validation","validationCode":"func assertNestedSetNotDynamic(a *configschema.Attribute) error {\n    if a.NestedType == nil || a.NestedType.Nesting != configschema.NestingSet { return nil }\n    if a.ImpliedType().HasDynamicTypes() {\n        return fmt.Errorf(\"NestingSet attribute may not contain cty.DynamicPseudoType\")\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Avoid cty.DynamicPseudoType inside any NestingSet attribute — sets need concrete hashable types.","Use a concrete object type or cty.Map for arbitrary key/value data inside a set.","Fall back to NestingList if dynamic typing is genuinely required."],"tags":["configschema","attribute","nestedtype","nesting-set","dynamic-type","cty","validation"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}