{"record":{"id":"f29b499e2c454a7f","repo":"hashicorp/terraform","slug":"lost-consul-lock-cannot-re-lock","errorCode":null,"errorMessage":"lost consul lock, cannot re-lock","messagePattern":"lost consul lock, cannot re-lock","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/backend/remote-state/consul/client.go","lineNumber":378,"sourceCode":"}\n\nfunc (c *RemoteClient) Lock(info *statemgr.LockInfo) (string, error) {\n\tc.mu.Lock()\n\tdefer c.mu.Unlock()\n\n\tif !c.lockState {\n\t\treturn \"\", nil\n\t}\n\n\tc.info = info\n\n\t// These checks only are to ensure we strictly follow the specification.\n\t// Terraform shouldn't ever re-lock, so provide errors for the 2 possible\n\t// states if this is called.\n\tselect {\n\tcase <-c.lockCh:\n\t\t// We had a lock, but lost it.\n\t\treturn \"\", errors.New(\"lost consul lock, cannot re-lock\")\n\tdefault:\n\t\tif c.lockCh != nil {\n\t\t\t// we have an active lock already\n\t\t\treturn \"\", fmt.Errorf(\"state %q already locked\", c.Path)\n\t\t}\n\t}\n\n\treturn c.lock()\n}\n\n// the lock implementation.\n// Only to be called while holding Client.mu\nfunc (c *RemoteClient) lock() (string, error) {\n\t// We create a new session here, so it can be canceled when the lock is\n\t// lost or unlocked.\n\tlockSession, err := c.createSession()\n\tif err != nil {\n\t\treturn \"\", err","sourceCodeStart":360,"sourceCodeEnd":396,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/backend/remote-state/consul/client.go#L360-L396","documentation":"NestingGroup blocks cannot be marked Computed. NestingGroup guarantees the block is always present (never null) with attribute defaults, which conflicts with the Computed semantics where the provider supplies the value. Combining them is rejected.","triggerScenarios":"A NestedBlock with Nesting: NestingGroup and Computed: true. Guard at internal_validate.go:85 is `blockS.Computed`.","commonSituations":"Migrating a computed NestingSingle to NestingGroup without clearing Computed; wanting provider-supplied defaults inside a group block.","solutions":["Set Computed: false on the NestingGroup block (group attributes can still be individually Computed).","If you need a computed single instance, use NestingSingle with Computed instead of NestingGroup."],"exampleFix":"// before\n\"defaults\": {\n  Nesting: configschema.NestingGroup,\n  Block: configschema.Block{Computed: true},\n},\n// after\n\"defaults\": {\n  Nesting: configschema.NestingGroup,\n  Block: configschema.Block{\n    Attributes: map[string]*configschema.Attribute{\n      \"value\": { Type: cty.String, Computed: true, Optional: true },\n    },\n  },\n},","handlingStrategy":"validation","validationCode":"// NestingGroup must not be Computed.\nfunc validGroupComputed(nb *configschema.NestedBlock) bool {\n    return nb.Nesting != configschema.NestingGroup || !nb.Computed\n}","typeGuard":"func groupNotComputed(nesting configschema.NestingMode, computed bool) bool {\n    return nesting != configschema.NestingGroup || !computed\n}","tryCatchPattern":null,"preventionTips":["Keep Computed off NestingGroup blocks; mark individual attributes Computed instead.","Use NestingSingle with Computed if you need a computed single block.","Document the group invariant in schema helpers."],"tags":["schema-validation","configschema","nestinggroup","computed","provider-schema"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}