{"record":{"id":"cecc937d9fb97245","repo":"hashicorp/terraform","slug":"the-secret-name-secretname-is-invalid-errs","errorCode":null,"errorMessage":"the secret name ${secretName} is invalid, ${errs}\nThis is a requirement for Kubernetes secret names. \nThe workspace name and key must adhere to Kubernetes naming conventions.","messagePattern":"the secret name (.+?) is invalid, (.+?)\nThis is a requirement for Kubernetes secret names\\. \nThe workspace name and key must adhere to Kubernetes naming conventions\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/backend/remote-state/kubernetes/client.go","lineNumber":420,"sourceCode":"\tdelProp := metav1.DeletePropagationBackground\n\tdelOps := metav1.DeleteOptions{PropagationPolicy: &delProp}\n\treturn c.kubernetesLeaseClient.Delete(context.Background(), name, delOps)\n}\n\nfunc (c *RemoteClient) createSecretName(idx int) (string, error) {\n\tsecretName := strings.Join([]string{tfstateKey, c.workspace, c.nameSuffix}, \"-\")\n\n\tif idx > 0 {\n\t\tsecretName = fmt.Sprintf(\"%s-part-%d\", secretName, idx)\n\t}\n\n\terrs := validation.IsDNS1123Subdomain(secretName)\n\tif len(errs) > 0 {\n\t\tk8sInfo := `\nThis is a requirement for Kubernetes secret names. \nThe workspace name and key must adhere to Kubernetes naming conventions.`\n\t\tmsg := fmt.Sprintf(\"the secret name %v is invalid, \", secretName)\n\t\treturn \"\", errors.New(msg + strings.Join(errs, \",\") + k8sInfo)\n\t}\n\n\treturn secretName, nil\n}\n\nfunc (c *RemoteClient) createLeaseName() (string, error) {\n\tn, err := c.createSecretName(0)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn \"lock-\" + n, nil\n}\n\nfunc compressState(data []byte) ([]byte, error) {\n\tb := new(bytes.Buffer)\n\tgz := gzip.NewWriter(b)\n\tif _, err := gz.Write(data); err != nil {\n\t\treturn nil, err","sourceCodeStart":402,"sourceCodeEnd":438,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/backend/remote-state/kubernetes/client.go#L402-L438","documentation":"A NestedBlock's Nesting field is not one of the recognized NestingMode constants (NestingSingle, NestingGroup, NestingList, NestingSet, NestingMap). The default zero value is nestingModeInvalid, so an unset Nesting field, or a corrupted/out-of-range value, lands in the default switch branch and is rejected.","triggerScenarios":"A NestedBlock literal that omits the Nesting field (defaults to nestingModeInvalid=0), or assigns an int value outside the declared enum. The default case at internal_validate.go:117 fires.","commonSituations":"Initializing a NestedBlock struct without setting Nesting; casting an arbitrary integer into NestingMode; schema generation that emits a zero nesting mode.","solutions":["Set Nesting to one of NestingSingle, NestingGroup, NestingList, NestingSet, or NestingMap.","If the value comes from codegen, ensure the generator always emits a valid constant.","Default to NestingList for typical repeatable blocks."],"exampleFix":"// before\n\"settings\": {\n  Block: configschema.Block{Attributes: ...},\n  // Nesting omitted -> nestingModeInvalid\n},\n// after\n\"settings\": {\n  Nesting: configschema.NestingList,\n  Block: configschema.Block{Attributes: ...},\n},","handlingStrategy":"validation","validationCode":"// Ensure the Nesting field is a recognized constant.\nfunc validNesting(n configschema.NestingMode) bool {\n    switch n {\n    case configschema.NestingSingle, configschema.NestingGroup,\n        configschema.NestingList, configschema.NestingSet, configschema.NestingMap:\n        return true\n    }\n    return false\n}","typeGuard":"func isValidNesting(n configschema.NestingMode) bool {\n    return n >= configschema.NestingSingle && n <= configschema.NestingMap\n}","tryCatchPattern":null,"preventionTips":["Always set the Nesting field explicitly on every NestedBlock.","Default to NestingList for repeatable blocks when unsure.","If generating schemas, assert the produced Nesting is a known constant."],"tags":["schema-validation","configschema","nestingmode","enum","provider-schema"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}