{"record":{"id":"05efbef20d455acc","repo":"microsoft/aspire","slug":"aspireradius043","errorCode":"ASPIRERADIUS043","errorMessage":"Secret-store data key '{key}' is declared more than once. Diagnostic: ASPIRERADIUS043.","messagePattern":"Secret-store data key '(.+?)' is declared more than once\\. Diagnostic: ASPIRERADIUS043\\.","errorType":"validation","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Radius/Secrets/RadiusSecretStoreExtensions.cs","lineNumber":442,"sourceCode":"\n        // A Secret data key that is not a valid Kubernetes key (e.g. 'bad/key') would only be rejected\n        // when the store is applied to the cluster; fail at the API boundary instead.\n        if (!KubernetesName.IsValidSecretDataKey(key))\n        {\n            throw new ArgumentException(\n                $\"Secret data key '{key}' is invalid. A Kubernetes Secret key must be 1-253 characters, may contain only \" +\n                \"alphanumeric characters, '-', '_', or '.', and may not be '.' or '..' or start with '..'. \" +\n                \"Diagnostic: ASPIRERADIUS067.\",\n                nameof(key));\n        }\n\n        // Reject a duplicate inline key rather than silently overwriting the earlier binding via the\n        // dictionary indexer: a silent overwrite would hide a duplicate declaration from the\n        // ASPIRERADIUS043 gate and could bind the store to the wrong parameter. This mirrors the\n        // duplicate-key rejection applied to the existing/sealed key list.\n        if (!_population.Data.TryAdd(key, new RadiusSecretKeyBinding(parameter.Resource, encoding?.ToRadiusEncodingString())))\n        {\n            throw new InvalidOperationException(\n                $\"Secret-store data key '{key}' is declared more than once. Diagnostic: ASPIRERADIUS043.\");\n        }\n\n        return this;\n    }\n}\n","sourceCodeStart":424,"sourceCodeEnd":449,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Radius/Secrets/RadiusSecretStoreExtensions.cs#L424-L449","documentation":"The inline-data population dictionary rejects a key added twice instead of silently overwriting the earlier binding. A silent overwrite would hide a duplicate declaration from the ASPIRERADIUS043 gate and could bind the store to the wrong parameter. This mirrors the duplicate-key rejection in the existing/sealed key list.","triggerScenarios":"Calling Add(key, ...) twice on the same secret-store builder with the same key string (ordinal comparison), e.g. Add(\"password\", p1) followed by Add(\"password\", p2).","commonSituations":"Looping over configuration where two sources produce the same key; copy-pasted binding lines; merging key sets from two code paths that overlap.","solutions":["Remove or rename the duplicate Add call so each inline key is declared once.","If rebinding intentionally, refactor so the key is added once with the correct parameter.","Deduplicate the source collection (e.g. Distinct by key, or last-wins on your side) before calling Add."],"exampleFix":"// before\nstore.WithData().Add(\"password\", p1);\nstore.WithData().Add(\"password\", p2);\n// after\nstore.WithData().Add(\"password\", p2); // single declaration per key","handlingStrategy":"validation","validationCode":"var seen = new HashSet<string>(StringComparer.Ordinal);\nforeach (var k in keys) { if (!seen.Add(k)) throw new InvalidOperationException($\"duplicate key {k}\"); }","typeGuard":null,"tryCatchPattern":"try { population.Add(key, parameter); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"ASPIRERADIUS043\")) { /* resolve duplicate declaration */ }","preventionTips":["Track keys in a set as you call Add in loops","Deduplicate merged configuration sources before binding","Give intentionally distinct bindings distinct key names"],"tags":["duplicate-key","validation","radius"],"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"}