{"record":{"id":"44eea47d4362e1d0","repo":"microsoft/aspire","slug":"aspireradius041","errorCode":"ASPIRERADIUS041","errorMessage":"Secret store '{store.Name}' must declare exactly one population mode (WithData, WithExistingSecret, or WithSealedSecret); it declares {population.DeclaredModeCount}. Diagnostic: ASPIRERADIUS041.","messagePattern":"Secret store '(.+?)' must declare exactly one population mode \\(WithData, WithExistingSecret, or WithSealedSecret\\); it declares (.+?)\\. Diagnostic: ASPIRERADIUS041\\.","errorType":"validation","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Radius/Secrets/RadiusSecretStoreValidation.cs","lineNumber":126,"sourceCode":"        }\n\n        foreach (var store in stores)\n        {\n            ValidateStore(store);\n        }\n\n        ValidateNoDuplicateNames(stores);\n        ValidateConsumers(model);\n    }\n\n    private static void ValidateStore(RadiusSecretStoreResource store)\n    {\n        var population = store.Population;\n\n        // ASPIRERADIUS041 — exactly one population mode.\n        if (population.DeclaredModeCount != 1)\n        {\n            throw new InvalidOperationException(\n                $\"Secret store '{store.Name}' must declare exactly one population mode \" +\n                \"(WithData, WithExistingSecret, or WithSealedSecret); it declares \" +\n                $\"{population.DeclaredModeCount}. Diagnostic: ASPIRERADIUS041.\");\n        }\n\n        var declaredKeys = population.HasInlineData\n            ? population.Data.Keys.ToList()\n            : population.Keys;\n\n        // ASPIRERADIUS043 — duplicate keys. Inline keys are rejected as they are added (the data\n        // dictionary rejects a duplicate via RadiusSecretStoreDataBuilder.Add), so only the\n        // existing/sealed key list needs a duplicate scan here.\n        if (population.IsSecretReference)\n        {\n            var seen = new HashSet<string>(StringComparer.Ordinal);\n            foreach (var key in population.Keys)\n            {\n                if (!seen.Add(key))","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Radius/Secrets/RadiusSecretStoreValidation.cs#L108-L144","documentation":"ASPIRERADIUS041 requires each secret store to declare exactly one population mode: WithData, WithExistingSecret, or WithSealedSecret. ValidateStore counts the declared modes via population.DeclaredModeCount and throws when it is zero or more than one. This prevents ambiguous or empty population definitions.","triggerScenarios":"Creating a store without calling any of WithData/WithExistingSecret/WithSealedSecret (count 0), or calling two of them on the same store (count 2), then running validation.","commonSituations":"Copy-pasting a second population call onto an existing store; forgetting the population call entirely; refactoring that combines two samples' population styles.","solutions":["Keep exactly one population call per store; remove the extra WithData/WithExistingSecret/WithSealedSecret call.","If the store has no population yet, add one (e.g. WithData()).","Split into two separate secret stores if both population modes are genuinely needed."],"exampleFix":"// before\nvar store = builder.AddRadiusSecretStore(\"s\", ...)\n    .WithData()\n    .WithExistingSecret(...);\n// after\nvar store = builder.AddRadiusSecretStore(\"s\", ...)\n    .WithData();","handlingStrategy":"validation","validationCode":"var modes = 0;\nif (usedWithData) modes++;\nif (usedExistingSecret) modes++;\nif (usedSealedSecret) modes++;\nif (modes != 1) throw new InvalidOperationException($\"store must declare exactly one population mode, got {modes}\");","typeGuard":null,"tryCatchPattern":"try { /* validation runs */ }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"ASPIRERADIUS041\")) { /* fix population calls */ }","preventionTips":["Chain exactly one population method per store builder","Don't merge samples that use different population styles onto one store","Create separate stores when multiple population sources are needed"],"tags":["validation","radius","conflicting-options"],"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"}