{"record":{"id":"842a9b5ef70b60ae","repo":"microsoft/aspire","slug":"resource-resource-name-maps-both-origins-valueskey-and","errorCode":null,"errorMessage":"Resource '{resource.Name}' maps both {origins[valuesKey]} and {origin} to Helm values path '{helmKey}.{resourceKey}.{valuesKey}'. Rename one of them so each value has a unique Helm path.","messagePattern":"Resource '(.+?)' maps both (.+?) and (.+?) to Helm values path '(.+?)\\.(.+?)\\.(.+?)'\\. Rename one of them so each value has a unique Helm path\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Kubernetes/KubernetesPublishingContext.cs","lineNumber":245,"sourceCode":"                if (!result.TryGetValue(valuesKey, out var existing))\n                {\n                    result.Add(valuesKey, value);\n                    origins.Add(valuesKey, origin);\n                    continue;\n                }\n\n                if (value.ParameterSource is not null &&\n                    ReferenceEquals(existing.ParameterSource, value.ParameterSource))\n                {\n                    if (value.IsEmbeddedParameter && !existing.IsEmbeddedParameter)\n                    {\n                        result[valuesKey] = value;\n                    }\n\n                    continue;\n                }\n\n                throw new InvalidOperationException(\n                    $\"Resource '{resource.Name}' maps both {origins[valuesKey]} and {origin} \" +\n                    $\"to Helm values path '{helmKey}.{resourceKey}.{valuesKey}'. Rename one of them \" +\n                    \"so each value has a unique Helm path.\");\n            }\n        }\n\n        return result;\n    }\n\n    private async Task AddValuesToHelmSectionAsync(\n        IResource resource,\n        Dictionary<string, KubernetesResource.HelmValue> contextItems,\n        string helmKey)\n    {\n        if (contextItems.Count <= 0 || _helmValues[helmKey] is not Dictionary<string, object> helmSection)\n        {\n            return;\n        }","sourceCodeStart":227,"sourceCodeEnd":263,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Kubernetes/KubernetesPublishingContext.cs#L227-L263","documentation":"Thrown by MergeHelmValueMappings in KubernetesPublishingContext when two different origins (e.g. two different environment variable sources or endpoints) both resolve to the same Helm values path '{helmKey}.{resourceKey}.{valuesKey}'. The Kubernetes publisher requires a one-to-one mapping between source values and Helm values paths so generated manifests are unambiguous. It refuses to silently overwrite one value with another.","triggerScenarios":"Running the Kubernetes publisher (parameterItems/configItems/secretItems) on a resource where two config/environment sources map to the same valuesKey, e.g. two parameters that normalize to the same Helm section name, or an env var and a parameter both colliding on '{helmKey}.{resourceKey}.{valuesKey}'.","commonSituations":"Defining two AddParameter calls whose names normalize to the same Helm values key; assigning the same environment variable name via different APIs (WithEnvironment and a parameter binding); renaming a parameter so it now collides with an existing one after a version upgrade.","solutions":["Rename one of the conflicting sources (parameter name or values key) so each has a unique Helm values path","Use the Helm values-key customization API to set an explicit distinct ValuesKey for one of the conflicting mappings","Remove the duplicate source if one of the two values is redundant","Inspect the published Helm values section for the resource to identify which two origins collide"],"exampleFix":"// before\nvar para = builder.AddParameter(\"db-connection\");\nvar para2 = builder.AddParameter(\"db_connection\"); // both normalize to 'db-connection'\n// after\nvar para = builder.AddParameter(\"db-connection\");\nvar para2 = builder.AddParameter(\"db-connection-string\"); // unique Helm values path","handlingStrategy":"validation","validationCode":"var names = myParameters.Select(p => p.Name.ToHelmValuesSectionName()).ToList();\nif (names.Count != names.Distinct().Count()) throw new InvalidOperationException(\"Duplicate Helm values keys detected\");","typeGuard":null,"tryCatchPattern":"try { await publishingContext.WriteAsync(outputPath); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"maps both\")) { logger.LogError(ex, \"Helm values path collision: {Msg}\", ex.Message); throw; }","preventionTips":["Keep parameter names unique per resource and avoid names that normalize identically","Review Helm values section output in CI publish smoke tests","Set explicit ValuesKeys when names could collide"],"tags":["kubernetes","helm","publishing","naming-collision"],"backgroundTag":"conflicting-config-options","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}