{"record":{"id":"6f18d53146626f0e","repo":"hashicorp/terraform","slug":"state-locked","errorCode":null,"errorMessage":"state locked","messagePattern":"state locked","errorType":"console","errorClass":"LockError","httpStatus":null,"severity":"error","filePath":"internal/backend/remote-state/inmem/backend.go","lineNumber":186,"sourceCode":"}\n\n// Global level locks for inmem backends.\ntype lockMap struct {\n\tsync.Mutex\n\tm map[string]*statemgr.LockInfo\n}\n\nfunc (l *lockMap) lock(name string, info *statemgr.LockInfo) (string, error) {\n\tl.Lock()\n\tdefer l.Unlock()\n\n\tlockInfo := l.m[name]\n\tif lockInfo != nil {\n\t\tlockErr := &statemgr.LockError{\n\t\t\tInfo: lockInfo,\n\t\t}\n\n\t\tlockErr.Err = errors.New(\"state locked\")\n\t\t// make a copy of the lock info to avoid any testing shenanigans\n\t\t*lockErr.Info = *lockInfo\n\t\treturn \"\", lockErr\n\t}\n\n\tinfo.Created = time.Now().UTC()\n\tl.m[name] = info\n\n\treturn info.ID, nil\n}\n\nfunc (l *lockMap) unlock(name, id string) error {\n\tl.Lock()\n\tdefer l.Unlock()\n\n\tlockInfo := l.m[name]\n\n\tif lockInfo == nil {","sourceCodeStart":168,"sourceCodeEnd":204,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/backend/remote-state/inmem/backend.go#L168-L204","documentation":"A NestingSet block may not contain attributes whose type resolves to cty.DynamicPseudoType. The cty set implementation hashes elements by their concrete type, so it cannot store elements of unknown/mixed type. The validator computes the block's implied type and rejects it if any leaf is dynamic.","triggerScenarios":"NestingSet block containing an attribute of type cty.DynamicPseudoType (directly or nested). Guard at internal_validate.go:94 is `ety := blockS.Block.ImpliedType(); ety.HasDynamicTypes()`.","commonSituations":"Using a free-form JSON attribute (cty.DynamicPseudoType) inside a set-valued block; migrating a NestingList with dynamic attrs to NestingSet.","solutions":["Replace cty.DynamicPseudoType with a concrete type (e.g. cty.String for JSON-in-string, or a defined object type).","Switch the block from NestingSet to NestingList, which has no such constraint.","Wrap dynamic payloads in a string-typed attribute holding serialized JSON."],"exampleFix":"// before\n\"rules\": {\n  Nesting: configschema.NestingSet,\n  Block: configschema.Block{Attributes: map[string]*configschema.Attribute{\n    \"data\": { Type: cty.DynamicPseudoType, Optional: true },\n  }},\n},\n// after\n\"rules\": {\n  Nesting: configschema.NestingSet,\n  Block: configschema.Block{Attributes: map[string]*configschema.Attribute{\n    \"data\": { Type: cty.String, Optional: true }, // store JSON as string\n  }},\n},","handlingStrategy":"validation","validationCode":"// Reject NestingSet blocks whose implied type has dynamic leaves.\nfunc setHasDynamic(nb *configschema.NestedBlock) bool {\n    if nb.Nesting != configschema.NestingSet { return false }\n    return nb.Block.ImpliedType().HasDynamicTypes()\n}","typeGuard":"// noDynamicTypes returns true when the block's implied type is free of cty.DynamicPseudoType.\nfunc noDynamicTypes(b *configschema.Block) bool {\n    return !b.ImpliedType().HasDynamicTypes()\n}","tryCatchPattern":null,"preventionTips":["Never use cty.DynamicPseudoType inside a NestingSet block.","Use a concrete object type or cty.String for JSON payloads.","Switch to NestingList if dynamic types are essential."],"tags":["schema-validation","configschema","nestingset","cty","dynamic-type","provider-schema"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}