{"record":{"id":"fe1f7b4fa506baaa","repo":"kubernetes/kops","slug":"duplicate-variable-found-s","errorCode":null,"errorMessage":"duplicate variable found: %s","messagePattern":"duplicate variable found: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/terraformWriter/writer.go","lineNumber":259,"sourceCode":"\n\t\ttfName := sanitizeName(res.ResourceName)\n\n\t\tif resources[tfName] != nil {\n\t\t\treturn nil, fmt.Errorf(\"duplicate resource found: %s.%s\", res.ResourceType, tfName)\n\t\t}\n\n\t\tresources[tfName] = res.Item\n\t}\n\n\treturn resourcesByType, nil\n}\n\nfunc (t *TerraformWriter) GetOutputs() (map[string]OutputValue, error) {\n\tvalues := map[string]OutputValue{}\n\tfor _, v := range t.outputs {\n\t\ttfName := sanitizeName(v.Key)\n\t\tif _, found := values[tfName]; found {\n\t\t\treturn nil, fmt.Errorf(\"duplicate variable found: %s\", tfName)\n\t\t}\n\t\tdeduped, err := dedupLiterals(v.ValueArray)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tvalues[tfName] = OutputValue{\n\t\t\tValue:      v.Value,\n\t\t\tValueArray: deduped,\n\t\t}\n\t}\n\treturn values, nil\n}\n","sourceCodeStart":241,"sourceCodeEnd":272,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/terraformWriter/writer.go#L241-L272","documentation":"Thrown by TerraformWriter.GetOutputs when two distinct output entries sanitize to the same Terraform output name — i.e. the outputs list contains a duplicate after name sanitization (dashes/cases collapsing to the same tfName). Terraform does not allow duplicate output names, so the generated HCL would be invalid.","triggerScenarios":"Thrown at upup/pkg/fi/cloudup/terraformWriter/writer.go:259 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Find which two output keys sanitize to the same name (the error prints the tfName) and rename one in the task definitions","Avoid emitting both a raw and a sanitized variant of the same key from tasks","Add a unit check when adding new outputs so names stay unique after sanitization"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}