Skip to content

Add Radius recipe parameters and secret management - #18778

Closed
Nell Shamrell-Harrington (nellshamrell) wants to merge 7 commits into
microsoft:mainfrom
nellshamrell:radius/pr2-recipes-and-secrets
Closed

Nell Shamrell-Harrington (nellshamrell) wants to merge 7 commits into
microsoft:mainfrom
nellshamrell:radius/pr2-recipes-and-secrets

Conversation

@nellshamrell

@nellshamrell Nell Shamrell-Harrington (nellshamrell) commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Description

This is the second slice of the Aspire→Radius integration, layered on the merged compute-environment baseline (#18696). It adds two independent, opt-in capabilities, plus hardening from code-review and architectural/API design review.

Recipe parameters — WithRecipeParameters(...)

Flow platform/recipe configuration values from the AppHost to the Radius recipe pack:

  • Environment-wide and resource-type-scoped values are applied to the recipe pack (UDT types) and legacy environment recipe entries.
  • ParameterResource-backed values emit as valueless @secure() Bicep params bound at deploy time — values are never inlined into the generated Bicep.
  • Provider references (e.g. RadiusProviderReference.AwsRegion) resolve at publish.
  • ASPIRERADIUS028 guards recipe-parameter identifier collisions with an actionable message.
builder.AddRadiusEnvironment("prod")
    .WithRecipeParameters(p =>
    {
        p["region"] = RadiusProviderReference.AwsRegion;
        p["apiKey"] = builder.AddParameter("apiKey", secret: true);
    });

Secret management (experimental — ASPIRERADIUS006)

AddRadiusSecretStore / WithSecretStore model Radius secret stores with three population modes and recipeConfig consumers:

  • Inline data (WithData), existing cluster secrets (WithExistingSecret), and sealed secrets (WithSealedSecret, applied via a dedicated pipeline step after publish and before deploy).
  • Secret values are never inlined into Bicep; sealed-secret manifests are copied alongside published artifacts.
  • Fail-fast validation surfaces ASPIRERADIUS040–062 diagnostics with actionable messages.

Hardening (review follow-ups on this branch)

Subsequent commits address code-review and design-review findings:

  • Sealed-secret robustness: duplicate-key/plaintext-capable manifests rejected via a real YAML parser (044); deploy waits on the controller's Synced status for the applied generation before checking the Secret (058); the kube-context is resolved from the active rad workspace and fails closed rather than applying to kubectl's ambient context (059, overridable via ASPIRE_RADIUS_KUBE_CONTEXT); declared keys are verified to exist in the materialized Secret (061); raw kubectl JSON containing secret material is never logged.
  • Fail-loud instead of silent no-ops: gateway TLS (WithTlsCertificate) is rejected until Radius gateways are modeled (060); WithMaterializationTimeout is restricted to sealed stores (062); the unusable WithTerraformProviderSecret API was removed.
  • ATS/polyglot conformance: every [AspireExportIgnore] on the new surface carries a Reason, and secret-store name params carry [ResourceName].
  • Latest review follow-ups: SealedSecretManifest.ValidateStructure now guards the mapping/sequence stack so malformed YAML fails as ASPIRERADIUS044 instead of a raw InvalidOperationException; the recipe-parameter README example uses the modern canonical type Radius.Data/redisCaches; and the sealed-secret materialization-timeout test was made deterministic (removing a wall-clock flake).

Design notes

  • Unified parameter registry: recipe and inline-secret parameters share the existing container env-var parameter registry, so a parameter used by both a recipe/secret value and a container env var emits a single Bicep param with one deploy binding. Two distinct parameters whose names normalize to the same Bicep identifier fail loudly with ASPIRERADIUS056 rather than silently misbinding.
  • Additive only: existing PR1 behavior (compute environment, cloud providers, options.Parameters emission, the secure-parameters deploy path) is preserved unchanged.

Testing

  • All Aspire.Hosting.Radius.Tests pass (307 tests), including new coverage for recipe parameters, all three secret-store modes, sealed-secret publish/apply/materialization, deploy-parameter unification, fail-closed kube-context resolution, declared-key validation, and identifier-collision regression cases.
  • src and test projects build clean under warnings-as-errors.

Follow-up

Gateway TLS emission (Radius gateways), multiple Radius resource groups, and per-instance recipe/type customization (PublishAsRadiusResource) are intentionally not in this PR and are planned for follow-up releases.

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No

Copilot AI review requested due to automatic review settings July 14, 2026 18:30
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 18778

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 18778"

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR introduces Radius “production & platform” capabilities: recipe parameters and secret-store support (including GitOps sealed secrets), plus publishing/deploy pipeline gates and associated tests/documentation.

Changes:

  • Add recipe-parameter annotations + Bicep emission (with ParameterResource bindings and provider references).
  • Add Radius secret-store resources, validation gate, consumers, and sealed-secret publish/deploy flow (manifest validation, artifact copy, kubectl apply + wait).
  • Add extensive test coverage for validation, Bicep output, and sealed-secret deploy behavior.

Reviewed changes

Copilot reviewed 40 out of 40 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/Aspire.Hosting.Radius/Secrets/SealedSecretManifest.cs Adds sealed-secret manifest validation + metadata extraction used by publish/deploy.
src/Aspire.Hosting.Radius/Publishing/SealedSecretApplyStep.cs Adds deploy-time kubectl apply + poll gate for sealed secrets.
src/Aspire.Hosting.Radius/Secrets/RadiusSecretStoreValidation.cs Adds fail-fast model validation for secret stores and consumer wiring.
src/Aspire.Hosting.Radius/Publishing/RadiusInfrastructureBuilder.cs Emits secretStores + recipe parameters into Bicep and deploy bindings.
src/Aspire.Hosting.Radius/Publishing/RadiusBicepPublishingContext.cs Copies validated sealed-secret manifests into the publish artifact.
src/Aspire.Hosting.Radius/README.md Documents recipe parameters and secret management capabilities and diagnostics.
tests/Aspire.Hosting.Radius.Tests/** Adds unit tests for recipe parameters, secret-store validation, Bicep emission, and sealed-secret deploy logic.
Comments suppressed due to low confidence (1)

src/Aspire.Hosting.Radius/README.md:1

  • Code paths in RadiusInfrastructureBuilder throw ASPIRERADIUS050 when an environment references a secret store that is not emitted for that environment. This diagnostic is not currently listed in the README’s “Runtime validation codes” table; please document it (or remove/replace the diagnostic if it’s not intended to be user-facing).
# Radius hosting integration

Comment thread src/Aspire.Hosting.Radius/README.md Resolved
@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@nellshamrell

Copy link
Copy Markdown
Contributor Author

PR Testing Report

PR Information

Artifact Version Verification

  • Expected Commit: 426f90ee
  • Installed CLI Version: 13.5.0-pr.18778.g426f90ee
  • Hive package: Aspire.Hosting.Radius.13.5.0-pr.18778.g426f90ee.nupkg
  • Status: ✅ Verified (version string contains PR head short SHA)

Changes Analyzed

Change Categories

  • Hosting integration changes — src/Aspire.Hosting.Radius/ (24 files)
  • Test changes — tests/Aspire.Hosting.Radius.Tests/ (16 files, 307 unit tests)
  • CLI / Dashboard / Templates / Components / VS Code / CI infrastructure

Public API surface exercised

AddRadiusSecretStore, WithData, WithExistingSecret, WithSecretStore, WithMaterializationTimeout,
WithRecipeParameters, WithBicepRegistryAuthentication, WithTerraformGitAuthentication,
WithRecipeEnvironmentSecret, WithTlsCertificate.

The Radius integration is publish/deploy-only (aspire run is a no-op for Radius). All testable
behavior without a live cluster is exercised via aspire publish (Bicep emission + config-time validation).
Sealed-secret apply/deploy (codes 044/045/058/059/061) needs a real Radius cluster + rad/kubectl/Sealed
Secrets controller and was not exercised here.

Test Scenarios Executed

Scenario 1: Recipe parameters + inline (Radius-created) secret store — happy path

Objective: Confirm recipe-parameter type fidelity and that secret parameter values are never inlined into Bicep.
Coverage Type: Happy path
Status: ✅ Passed

Steps: New file-based AppHost referencing PR hive Aspire.Hosting.Radius; AddRadiusEnvironment with
environment-wide + resource-type-scoped WithRecipeParameters; AddRadiusSecretStore(BasicAuthentication)

  • WithData binding two secret: true parameters; aspire publish.

Observations (from generated app.bicep):

  • Type fidelity preserved: region: 'eastus' (string), port: 6379 (number, unquoted), enabled: true (bool).
  • Secret store db-creds emitted as Applications.Core/secretStores, application: app_legacy.id (application-scoped).
  • Secret values referenced via @secure() param db_user / @secure() param db_pass — actual values (admin, s3cr3t-P@ss) never appear in any artifact. ✅ leak check clean.
  • Expected [WRN] for recipe params scoped to a resource type with no emitted recipe (documented behavior); publish still succeeds (7/7 steps).

Scenario 2a: ASPIRERADIUS062 — materialization timeout on a non-sealed store — unhappy path

Coverage Type: Unhappy path · Status: ✅ Passed
WithMaterializationTimeout on a WithData (inline) store causes aspire publish to fail at the
validate-radius-secret-stores gate with ASPIRERADIUS062 ("not populated with WithSealedSecret ... remove the call or use WithSealedSecret").
Expected Unhappy-Path Outcome: Publish pipeline fails fast with actionable message + diagnostic code. ✅

Scenario 2b: ASPIRERADIUS041 — two population modes — unhappy path

Coverage Type: Unhappy path · Status: ✅ Passed
A store declaring both WithData and WithExistingSecret fails publish with
ASPIRERADIUS041 ("must declare exactly one population mode ...; it declares 2").
Expected Unhappy-Path Outcome: Fail-fast validation gate error. ✅

Scenario 2c: ASPIRERADIUS054 — gateway TLS with an application-scoped store — unhappy path (fail-closed)

Coverage Type: Unhappy path · Status: ✅ Passed
WithTlsCertificate fed an application-scoped store throws InvalidOperationException ASPIRERADIUS054
at config time ("application-scoped and cannot be used for gateway TLS ... Declare it with WithSecretStore on an environment").
Gateway TLS is the documented not-yet-supported surface (060); this confirms it fails closed rather than silently dropping.
Expected Unhappy-Path Outcome: Explicit config-time failure. ✅

Scenario 3: Secret-store consumers emit recipeConfig — happy path

Objective: Confirm WithBicepRegistryAuthentication and WithRecipeEnvironmentSecret wire the store into recipeConfig by .id.
Coverage Type: Happy path · Status: ✅ Passed

Observations (from app.bicep):

recipeConfig: {
  bicep: {
    authentication: {
      'myregistry.azurecr.io': { secret: reg_creds.id }
    }
  }
  envSecrets: {
    DB_PASSWORD: { source: reg_creds.id, key: 'password' }
  }
}

Store referenced by symbol .id (never by bare name); no secret literal leaked (leak check clean); publish 7/7.

Summary

Scenario Type Status Notes
1. Recipe params + inline secret store Happy ✅ Passed Type fidelity; secrets via @secure(), never inlined
2a. ASPIRERADIUS062 Unhappy ✅ Passed Materialization timeout on non-sealed store rejected
2b. ASPIRERADIUS041 Unhappy ✅ Passed Two population modes rejected
2c. ASPIRERADIUS054 Unhappy ✅ Passed Gateway TLS on app-scoped store fails closed
3. Secret-store consumers Happy ✅ Passed recipeConfig authentication + envSecrets reference store .id

Notes / Minor Observations

  • App-scoped secret store with no AddRadiusEnvironment is a silent no-op: the secret-store validation
    gate is registered by RadiusEnvironmentResource, so an AppHost that adds AddRadiusSecretStore(...) but
    no Radius environment publishes successfully (4/4 steps) with the store neither validated nor emitted.
    This matches the "Radius participates only when an environment is present" model, but a user who forgets
    the environment gets no diagnostic. Non-blocking; worth considering a warning in a follow-up.
  • Gateway TLS is unreachable by design in this release: WithSecretStore returns an environment
    builder, so the only IResourceBuilder<RadiusSecretStoreResource> obtainable (via AddRadiusSecretStore)
    is application-scoped and rejected by WithTlsCertificate (054). Consistent with the README "not yet supported (060)".

Overall Result

✅ PR VERIFIED

All 5 scenarios (2 happy-path, 3 unhappy-path) passed against the dogfood PR CLI at head 426f90ee.
Recipe-parameter type fidelity, secret non-inlining (@secure()), consumer recipeConfig wiring, and the
new config-time/publish validation gates (041/054/062) all behave as documented. The 307-test unit suite is
also green. Sealed-secret deploy-time paths (cluster-dependent) were out of scope for this environment.

Recommendations

  • Consider a warning when a Radius secret store is declared without any AddRadiusEnvironment (silent no-op today).

Copilot AI review requested due to automatic review settings July 14, 2026 19:05
Second slice of the Aspire→Radius integration, layered on the merged
compute-environment baseline (microsoft#18696).

Recipe parameters (`WithRecipeParameters`):
- Flow environment-wide and resource-type-scoped values onto the recipe
  pack and legacy environment recipe entries.
- ParameterResource-backed values emit as valueless `@secure()` Bicep
  params bound at deploy time; provider references resolve at publish.
- ASPIRERADIUS028 guards recipe-parameter identifier collisions.

Secret management (gated behind experimental ASPIRERADIUS006):
- `AddRadiusSecretStore` / `WithSecretStore` with inline, existing-secret,
  and sealed-secret population modes plus `recipeConfig` consumers.
- Sealed secrets are applied via a dedicated pipeline step after publish
  and before deploy; secret values are never inlined into Bicep.
- Validation surfaces actionable ASPIRERADIUS040–055 diagnostics.

Recipe and secret parameters are unified with the existing container
env-var parameter registry so a parameter shared across both emits a
single Bicep `param` and one deploy binding; distinct parameters whose
names collide to the same identifier fail loudly (ASPIRERADIUS056)
rather than silently misbinding.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: f19583f4-384b-4601-a94b-290d9b0d4ed5
Address four findings from the code review of the sealed-secret path:

- Replace the regex/line-oriented SealedSecret manifest validator with a
  YamlDotNet parser. Reject duplicate keys, multi-document/non-mapping roots,
  anchors/aliases/merge keys, top-level data/stringData, and non-empty
  spec.template.data so a plaintext Kubernetes Secret can no longer be smuggled
  past validation into published artifacts or applied to a cluster.
- Close the validate/copy TOCTOU: read and validate the manifest once, carry the
  validated bytes, and write those exact bytes into the artifact instead of
  re-reading the source file.
- Gate the deploy-time materialization wait on the SealedSecret's status
  (observedGeneration match + Synced=True) before confirming the Secret, so a
  redeploy no longer proceeds with a stale Secret. Fast-fail on Synced=False or
  generation advance, enforce a per-probe remaining-time budget, and fail with
  ASPIRERADIUS058 on timeout. Raw kubectl -o json output is never logged.
- Fail closed (ASPIRERADIUS059) when the active rad workspace's Kubernetes
  context cannot be resolved, instead of silently using kubectl's ambient
  context, with an ASPIRE_RADIUS_KUBE_CONTEXT override escape hatch.

Update the README diagnostics table (broaden 044; add 058/059) and add tests.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: ddaf7f6d-b633-4b7e-9578-ec5b40e3c8e9
…tic doc

Address review feedback on the Radius secret-store API:

- Rename FromExistingSecret/FromSealedSecret to WithExistingSecret/
  WithSealedSecret so the configuration methods follow Aspire's With*
  convention (they configure an existing resource builder). Update all call
  sites, XML docs, validation messages, README examples, and tests.
- Remove the retired ASPIRERADIUS046 entry from the README diagnostics table;
  its "sealed Secret never materialized before deploy" meaning is now covered
  by the status-gated ASPIRERADIUS058.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: ddaf7f6d-b633-4b7e-9578-ec5b40e3c8e9
Fixes five design findings surfaced by architecture/hosting/api reviews on
the Radius recipe & secret-store surface:

1. Gateway TLS (WithTlsCertificate) now fails loud instead of silently
   dropping: rejected at the validation gate (ASPIRERADIUS060), with a
   defensive throw at emission.
2. Remove the unusable WithTerraformProviderSecret API (and its enum member,
   ASPIRERADIUS053 validation, emission case, test, and README refs).
3. Restrict WithMaterializationTimeout to sealed stores: reject an explicit
   override on a non-sealed store (ASPIRERADIUS062).
4. Validate declared keys exist in the materialized sealed Secret at deploy
   (ASPIRERADIUS061); Secret values are never logged, only key names read.
5. ATS export conformance: add Reason to every [AspireExportIgnore] on the
   new Radius surface and [ResourceName] to the secret-store name params.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: ddaf7f6d-b633-4b7e-9578-ec5b40e3c8e9
- SealedSecretManifest.ValidateStructure: guard Stack.Pop() on MappingEnd/
  SequenceEnd so a malformed or out-of-sync YAML event stream fails as
  ASPIRERADIUS044 instead of escaping as a raw InvalidOperationException.
- README: use the modern canonical resource-type string Radius.Data/redisCaches
  in the recipe-parameter scoping example (matches WithRecipeParametersTests and
  RadiusResourceTypes.RedisCaches); Applications.Datastores/redisCaches is only
  the legacy fallback emission type.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: ddaf7f6d-b633-4b7e-9578-ec5b40e3c8e9

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 40 out of 40 changed files in this pull request and generated 1 comment.

Copilot AI review requested due to automatic review settings July 14, 2026 19:11
WaitForSealedSecretSynced_StatusMatchesButSecretAbsent_KeepsWaitingThenTimesOut
used a 10ms wall-clock timeout and asserted secretCalls > 1. On a loaded CI
runner a slow cold-JIT first iteration could consume the whole 10ms budget
before a second poll, so only one secretExists call happened and the assertion
failed. The probe now reports the Secret absent on the first call (so the loop
keeps waiting past one iteration) and hangs on the second so the SUT's
remaining-budget guard cancels it and surfaces the real ASPIRERADIUS058 timeout,
guaranteeing at least two polls regardless of runner speed.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: ddaf7f6d-b633-4b7e-9578-ec5b40e3c8e9

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 40 out of 40 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

src/Aspire.Hosting.Radius/README.md:1

  • The code now throws ASPIRERADIUS050 in RadiusInfrastructureBuilder.ResolveSecretStoreReference(...) when an environment references a secret store that is not emitted for that environment, but this diagnostic code does not appear in the README’s “Runtime validation codes” table (which lists 028, 040–062, 056, etc.). Add an entry for ASPIRERADIUS050 (area: publish; meaning: secret-store consumer references a store not routed/emitted for the environment) so users can look it up and understand remediation.
# Radius hosting integration

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 40 out of 40 changed files in this pull request and generated 5 comments.

Comment on lines +80 to +82
var declaredKeys = population.HasInlineData
? population.Data.Keys.ToList()
: population.Keys;
Comment on lines +100 to +109
// ASPIRERADIUS040 — type-aware required keys.
foreach (var required in store.Type.RequiredKeys())
{
if (!declaredKeys.Contains(required, StringComparer.Ordinal))
{
throw new InvalidOperationException(
$"Secret store '{store.Name}' of type '{store.Type.ToRadiusTypeString()}' is missing " +
$"the required key '{required}'. Diagnostic: ASPIRERADIUS040.");
}
}
Comment on lines +1535 to +1544
// Scope is implied by the declaring API form: application-scoped stores reference the
// application; environment-scoped stores reference the environment.
if (store.Scope == RadiusSecretStoreScope.Application && legacyAppConstruct is not null)
{
construct.ApplicationId = BuildIdExpression(legacyAppConstruct);
}
else if (legacyEnvConstruct is not null)
{
construct.EnvironmentId = BuildIdExpression(legacyEnvConstruct);
}
Comment on lines +418 to +426
private static async Task<long> ApplyManifestAsync(string manifestPath, string? @namespace, string? kubeContext, ILogger logger, CancellationToken cancellationToken)
{
var args = BuildApplyArgs(manifestPath, kubeContext, @namespace);
var (exitCode, stdout, stderr) = await RunKubectlAsync(args, logger, cancellationToken, logStdout: false).ConfigureAwait(false);
if (exitCode != 0)
{
throw new InvalidOperationException(
$"'kubectl apply -f {manifestPath}' failed with exit code {exitCode}: {stderr.Trim()}");
}
Comment on lines +24 to +25
internal static string RelativePath(string storeName, string sourceManifestPath) =>
Path.Combine(RootDirectoryName, storeName, Path.GetFileName(sourceManifestPath));
…ostics

Address re-review feedback on PR microsoft#18778:

- SealedSecretManifest.ReadValidated: File.ReadAllBytes can throw
  ArgumentException (empty/whitespace/invalid-character path) and
  PathTooLongException, which previously escaped the catch filter without
  the ASPIRERADIUS044 wrapping promised by the XML-doc/README contract.
  Broaden the filter so every unreadable-manifest failure normalizes to
  ASPIRERADIUS044.

- SealedSecretApplyStep.ParseGeneration: the "did not return
  metadata.generation" throw omitted the SealedSecret/store identity and a
  diagnostic code. Thread the store name + namespace/name through and map
  the failure to ASPIRERADIUS058 for consistent triage.

Adds targeted tests for both paths.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: ddaf7f6d-b633-4b7e-9578-ec5b40e3c8e9
Copilot AI review requested due to automatic review settings July 14, 2026 19:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 40 out of 40 changed files in this pull request and generated 5 comments.

var requiredType = consumer.Kind switch
{
RadiusSecretStoreConsumerKind.BicepRegistryAuth => (RadiusSecretStoreType?)RadiusSecretStoreType.BasicAuthentication,
RadiusSecretStoreConsumerKind.TerraformGitPat => RadiusSecretStoreType.BasicAuthentication,
? store.Population.Data.Keys.ToList()
: store.Population.Keys;

if (declaredKeys.Count > 0 && !declaredKeys.Contains(key, StringComparer.Ordinal))
Comment on lines +61 to +64
foreach (var c in name)
{
if (!(char.IsAsciiLetterOrDigit(c) || c is '-' or '_' or '.'))
{
Comment on lines +90 to +93
public static IResourceBuilder<T> WithTlsCertificate<T>(
this IResourceBuilder<T> gateway,
IResourceBuilder<RadiusSecretStoreResource> store)
where T : IResource
s.WithExistingSecret("app/tls-cert", "tls.crt", "tls.key"));

// GitOps sealed secrets — the encrypted manifest is applied before rad deploy and awaited.
radius.WithSecretStore("db-creds", RadiusSecretStoreType.BasicAuthentication, s =>
@nellshamrell

Copy link
Copy Markdown
Contributor Author

Closing while I land a fix to the E2E Radius tests first, will re-open later.

@microsoft-github-policy-service microsoft-github-policy-service Bot added this to the 13.5 milestone Jul 15, 2026
Nell Shamrell-Harrington (nellshamrell) added a commit to nellshamrell/aspire that referenced this pull request Jul 20, 2026
…ostics

Address re-review feedback on PR microsoft#18778:

- SealedSecretManifest.ReadValidated: File.ReadAllBytes can throw
  ArgumentException (empty/whitespace/invalid-character path) and
  PathTooLongException, which previously escaped the catch filter without
  the ASPIRERADIUS044 wrapping promised by the XML-doc/README contract.
  Broaden the filter so every unreadable-manifest failure normalizes to
  ASPIRERADIUS044.

- SealedSecretApplyStep.ParseGeneration: the "did not return
  metadata.generation" throw omitted the SealedSecret/store identity and a
  diagnostic code. Thread the store name + namespace/name through and map
  the failure to ASPIRERADIUS058 for consistent triage.

Adds targeted tests for both paths.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: ddaf7f6d-b633-4b7e-9578-ec5b40e3c8e9
Nell Shamrell-Harrington (nellshamrell) added a commit to nellshamrell/aspire that referenced this pull request Jul 20, 2026
…ostics

Address re-review feedback on PR microsoft#18778:

- SealedSecretManifest.ReadValidated: File.ReadAllBytes can throw
  ArgumentException (empty/whitespace/invalid-character path) and
  PathTooLongException, which previously escaped the catch filter without
  the ASPIRERADIUS044 wrapping promised by the XML-doc/README contract.
  Broaden the filter so every unreadable-manifest failure normalizes to
  ASPIRERADIUS044.

- SealedSecretApplyStep.ParseGeneration: the "did not return
  metadata.generation" throw omitted the SealedSecret/store identity and a
  diagnostic code. Thread the store name + namespace/name through and map
  the failure to ASPIRERADIUS058 for consistent triage.

Adds targeted tests for both paths.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: ddaf7f6d-b633-4b7e-9578-ec5b40e3c8e9
Nell Shamrell-Harrington (nellshamrell) added a commit to nellshamrell/aspire that referenced this pull request Jul 20, 2026
…ostics

Address re-review feedback on PR microsoft#18778:

- SealedSecretManifest.ReadValidated: File.ReadAllBytes can throw
  ArgumentException (empty/whitespace/invalid-character path) and
  PathTooLongException, which previously escaped the catch filter without
  the ASPIRERADIUS044 wrapping promised by the XML-doc/README contract.
  Broaden the filter so every unreadable-manifest failure normalizes to
  ASPIRERADIUS044.

- SealedSecretApplyStep.ParseGeneration: the "did not return
  metadata.generation" throw omitted the SealedSecret/store identity and a
  diagnostic code. Thread the store name + namespace/name through and map
  the failure to ASPIRERADIUS058 for consistent triage.

Adds targeted tests for both paths.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: ddaf7f6d-b633-4b7e-9578-ec5b40e3c8e9
Nell Shamrell-Harrington (nellshamrell) added a commit to nellshamrell/aspire that referenced this pull request Jul 27, 2026
…ostics

Address re-review feedback on PR microsoft#18778:

- SealedSecretManifest.ReadValidated: File.ReadAllBytes can throw
  ArgumentException (empty/whitespace/invalid-character path) and
  PathTooLongException, which previously escaped the catch filter without
  the ASPIRERADIUS044 wrapping promised by the XML-doc/README contract.
  Broaden the filter so every unreadable-manifest failure normalizes to
  ASPIRERADIUS044.

- SealedSecretApplyStep.ParseGeneration: the "did not return
  metadata.generation" throw omitted the SealedSecret/store identity and a
  diagnostic code. Thread the store name + namespace/name through and map
  the failure to ASPIRERADIUS058 for consistent triage.

Adds targeted tests for both paths.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: ddaf7f6d-b633-4b7e-9578-ec5b40e3c8e9
Mitch Denny (mitchdenny) pushed a commit that referenced this pull request Aug 10, 2026
* Add Radius recipe parameters and secret management

Second slice of the Aspire→Radius integration, layered on the merged
compute-environment baseline (#18696).

Recipe parameters (`WithRecipeParameters`):
- Flow environment-wide and resource-type-scoped values onto the recipe
  pack and legacy environment recipe entries.
- ParameterResource-backed values emit as valueless `@secure()` Bicep
  params bound at deploy time; provider references resolve at publish.
- ASPIRERADIUS028 guards recipe-parameter identifier collisions.

Secret management (gated behind experimental ASPIRERADIUS006):
- `AddRadiusSecretStore` / `WithSecretStore` with inline, existing-secret,
  and sealed-secret population modes plus `recipeConfig` consumers.
- Sealed secrets are applied via a dedicated pipeline step after publish
  and before deploy; secret values are never inlined into Bicep.
- Validation surfaces actionable ASPIRERADIUS040–055 diagnostics.

Recipe and secret parameters are unified with the existing container
env-var parameter registry so a parameter shared across both emits a
single Bicep `param` and one deploy binding; distinct parameters whose
names collide to the same identifier fail loudly (ASPIRERADIUS056)
rather than silently misbinding.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: f19583f4-384b-4601-a94b-290d9b0d4ed5

* Harden Radius sealed-secret handling from code-review findings

Address four findings from the code review of the sealed-secret path:

- Replace the regex/line-oriented SealedSecret manifest validator with a
  YamlDotNet parser. Reject duplicate keys, multi-document/non-mapping roots,
  anchors/aliases/merge keys, top-level data/stringData, and non-empty
  spec.template.data so a plaintext Kubernetes Secret can no longer be smuggled
  past validation into published artifacts or applied to a cluster.
- Close the validate/copy TOCTOU: read and validate the manifest once, carry the
  validated bytes, and write those exact bytes into the artifact instead of
  re-reading the source file.
- Gate the deploy-time materialization wait on the SealedSecret's status
  (observedGeneration match + Synced=True) before confirming the Secret, so a
  redeploy no longer proceeds with a stale Secret. Fast-fail on Synced=False or
  generation advance, enforce a per-probe remaining-time budget, and fail with
  ASPIRERADIUS058 on timeout. Raw kubectl -o json output is never logged.
- Fail closed (ASPIRERADIUS059) when the active rad workspace's Kubernetes
  context cannot be resolved, instead of silently using kubectl's ambient
  context, with an ASPIRE_RADIUS_KUBE_CONTEXT override escape hatch.

Update the README diagnostics table (broaden 044; add 058/059) and add tests.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: ddaf7f6d-b633-4b7e-9578-ec5b40e3c8e9

* Rename secret-store population methods to With* and fix stale diagnostic doc

Address review feedback on the Radius secret-store API:

- Rename FromExistingSecret/FromSealedSecret to WithExistingSecret/
  WithSealedSecret so the configuration methods follow Aspire's With*
  convention (they configure an existing resource builder). Update all call
  sites, XML docs, validation messages, README examples, and tests.
- Remove the retired ASPIRERADIUS046 entry from the README diagnostics table;
  its "sealed Secret never materialized before deploy" meaning is now covered
  by the status-gated ASPIRERADIUS058.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: ddaf7f6d-b633-4b7e-9578-ec5b40e3c8e9

* Address Radius secret-store design-review findings

Fixes five design findings surfaced by architecture/hosting/api reviews on
the Radius recipe & secret-store surface:

1. Gateway TLS (WithTlsCertificate) now fails loud instead of silently
   dropping: rejected at the validation gate (ASPIRERADIUS060), with a
   defensive throw at emission.
2. Remove the unusable WithTerraformProviderSecret API (and its enum member,
   ASPIRERADIUS053 validation, emission case, test, and README refs).
3. Restrict WithMaterializationTimeout to sealed stores: reject an explicit
   override on a non-sealed store (ASPIRERADIUS062).
4. Validate declared keys exist in the materialized sealed Secret at deploy
   (ASPIRERADIUS061); Secret values are never logged, only key names read.
5. ATS export conformance: add Reason to every [AspireExportIgnore] on the
   new Radius surface and [ResourceName] to the secret-store name params.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: ddaf7f6d-b633-4b7e-9578-ec5b40e3c8e9

* Address Copilot review feedback on Radius secret stores

- SealedSecretManifest.ValidateStructure: guard Stack.Pop() on MappingEnd/
  SequenceEnd so a malformed or out-of-sync YAML event stream fails as
  ASPIRERADIUS044 instead of escaping as a raw InvalidOperationException.
- README: use the modern canonical resource-type string Radius.Data/redisCaches
  in the recipe-parameter scoping example (matches WithRecipeParametersTests and
  RadiusResourceTypes.RedisCaches); Applications.Datastores/redisCaches is only
  the legacy fallback emission type.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: ddaf7f6d-b633-4b7e-9578-ec5b40e3c8e9

* Make sealed-secret timeout test deterministic (fix CI flake)

WaitForSealedSecretSynced_StatusMatchesButSecretAbsent_KeepsWaitingThenTimesOut
used a 10ms wall-clock timeout and asserted secretCalls > 1. On a loaded CI
runner a slow cold-JIT first iteration could consume the whole 10ms budget
before a second poll, so only one secretExists call happened and the assertion
failed. The probe now reports the Secret absent on the first call (so the loop
keeps waiting past one iteration) and hangs on the second so the SUT's
remaining-budget guard cancels it and surfaces the real ASPIRERADIUS058 timeout,
guaranteeing at least two polls regardless of runner speed.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: ddaf7f6d-b633-4b7e-9578-ec5b40e3c8e9

* Normalize manifest-path and apply-generation failures to Radius diagnostics

Address re-review feedback on PR #18778:

- SealedSecretManifest.ReadValidated: File.ReadAllBytes can throw
  ArgumentException (empty/whitespace/invalid-character path) and
  PathTooLongException, which previously escaped the catch filter without
  the ASPIRERADIUS044 wrapping promised by the XML-doc/README contract.
  Broaden the filter so every unreadable-manifest failure normalizes to
  ASPIRERADIUS044.

- SealedSecretApplyStep.ParseGeneration: the "did not return
  metadata.generation" throw omitted the SealedSecret/store identity and a
  diagnostic code. Thread the store name + namespace/name through and map
  the failure to ASPIRERADIUS058 for consistent triage.

Adds targeted tests for both paths.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: ddaf7f6d-b633-4b7e-9578-ec5b40e3c8e9

* Address code-review findings in Radius recipes + secrets

Fixes findings from code-review, rubber-duck, security, architecture, and
hosting-integration-authoring passes on the recipe-parameter and secret-store
work in Aspire.Hosting.Radius.

Secret handling:
- Reject plaintext `kind: Secret` embedded in a SealedSecret's
  last-applied-configuration annotation; fail closed on malformed/non-scalar
  annotation values and non-object data/stringData (ASPIRERADIUS063).
- Require an explicit metadata.namespace for application-scoped sealed stores so
  the namespace can't silently diverge per environment (ASPIRERADIUS055).
- Bound the kubectl apply/sync/verify sequence with a shared timeout budget
  (ASPIRERADIUS066); tolerate transient/NotFound `kubectl get sealedsecret`
  failures during polling instead of aborting the deploy.
- Reject key-specific envSecret consumers against keyless stores
  (ASPIRERADIUS064) and repeated population of a store (ASPIRERADIUS065);
  validate keys before mutating so a bad first key can't poison a retry.
- Fire the targeted duplicate-identifier diagnostic (ASPIRERADIUS048) for
  app-vs-env Bicep identifier collisions, matching the actual emission scope.

Recipe parameters:
- Convert ParameterResource/RadiusProviderReference nested inside recipe
  parameter objects/arrays recursively so they stay late-bound, with cycle and
  depth guards.

Cleanup:
- Remove the dead WithTlsCertificate/GatewayTls consumer API and stale
  gateway-TLS doc comments.

Adds unit tests for each finding and updates the README diagnostics table.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: b76dc20d-c553-47b7-8f5e-6fcdc0f10aa3

* Address PR #18834 review feedback for Radius secrets

Harden and tighten the Radius secret-store surface in response to Copilot
review comments:

- SealedSecretManifest: fail closed in EmbedsPlaintextSecret when the embedded
  last-applied-configuration has duplicate/missing/non-string kind or duplicate
  data/stringData, so a crafted payload cannot smuggle plaintext past a single
  TryGetProperty lookup.
- WithSealedSecret: resolve a relative manifest path against the AppHost
  directory (matching other hosting file APIs) so it works regardless of the
  process working directory.
- RadiusSecretStoreNaming: align the store-name grammar with Aspire's
  resource-name grammar (letters/digits/hyphens, start-with-letter, no
  consecutive/trailing hyphen, <=64) so publish mode (AddResource) never rejects
  a name run mode accepted. Update the ASPIRERADIUS049 message.
- WithData: add a single-key convenience overload binding a data key to a secret
  parameter, delegating transactionally to the callback form.
- SealedSecretApplyStep.GetSealedSecretStatusAsync: only treat SealedSecret
  NotFound or transient connectivity failures as retryable; surface permanent
  kubectl failures (auth/RBAC/context/missing plugin) immediately instead of
  waiting out the whole materialization budget.

Adds 22 targeted tests (357 total, all passing).

Co-authored-by: Copilot <[email protected]>
Copilot-Session: b76dc20d-c553-47b7-8f5e-6fcdc0f10aa3

* Address Radius re-review: Terraform Git PAT key requirement, duplicate inline key rejection, existing-secret reference validation

Re-review of PR #18834 raised three additional findings on the Radius
secret-store surface:

- Terraform Git PAT auth now requires the referenced store to declare a
  'pat' key (optionally 'username'), matching what Radius reads for
  recipeConfig.terraform.authentication.git.pat, instead of accepting a
  basicAuthentication username/password store it cannot use (ASPIRERADIUS051).
- RadiusSecretStoreDataBuilder.Add rejects a duplicate inline key via TryAdd
  instead of silently overwriting through the dictionary indexer, so a
  double-declared key surfaces at the call site (ASPIRERADIUS043).
- WithExistingSecret validates the '[namespace/]name' reference at the API
  boundary (single separator, DNS-1123 name/namespace) rather than deferring
  a malformed reference to deploy time (ASPIRERADIUS046).

Adds targeted tests and updates the README diagnostics table and xmldoc.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: b76dc20d-c553-47b7-8f5e-6fcdc0f10aa3

* Address Radius re-review: rewire secret stores on rename, bound materialization timeout, validate sealed manifest names

A second re-review round on PR #18834 raised three findings:

- ConfigureRadiusInfrastructure exposes secret stores (opts.SecretStores), but
  the identifier snapshot/rewire logic ignored them. Renaming a store construct
  left recipeConfig referencing the old <identifier>.id, and renaming the legacy
  application/environment left the store's ApplicationId/EnvironmentId pointing at
  stale symbols. Extended IdentifierSnapshot and added RewireSecretStoreReferences
  to rewrite both consumer references and parent scope IDs.
- WithMaterializationTimeout accepted values above int.MaxValue milliseconds (e.g.
  TimeSpan.MaxValue) that CancellationTokenSource.CancelAfter / the deploy deadline
  cannot represent, so they passed publish validation but threw at deploy. Reject
  them at configuration time.
- SealedSecret manifest parsing accepted any nonblank metadata.name (e.g. Bad_Name,
  a/b, an overlong namespace), deferring the failure to kubectl apply. Validate the
  name as a DNS-1123 subdomain and any explicit namespace as a DNS-1123 label at
  publish time, mirroring the WithExistingSecret fast-fail.

Extracted the DNS-1123 helpers into a shared KubernetesName class and added tests
for all three findings.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: b76dc20d-c553-47b7-8f5e-6fcdc0f10aa3

* Address Radius PR re-review round B (R1-R6)

- WithExistingSecret validates reference and keys before marking the store
  populated so a corrected retry is not blocked by ASPIRERADIUS065 (R1).
- Reject secret data keys that are not valid Kubernetes Secret keys at the API
  boundary for inline/existing/sealed populations (ASPIRERADIUS067) (R2).
- rad workspace kube-context fallback now returns the single distinct context
  only; multiple contexts fail closed instead of guessing (R3).
- Application-scoped store declared without any Radius environment now fails fast
  via a store-registered pipeline gate (ASPIRERADIUS068) (R4).
- Add remarks/example xmldoc to AddRadiusSecretStore and WithRecipeParameters (R5/R6).

Co-authored-by: Copilot <[email protected]>
Copilot-Session: b76dc20d-c553-47b7-8f5e-6fcdc0f10aa3

* Address Radius PR re-review rounds B2/B3 (N1-N8)

- IsValidSecretDataKey now matches apimachinery IsConfigMapKey semantics:
  reject keys >253 chars, '.'/'..', and keys starting with '..' (N1).
- IsTransientKubectlFailure no longer treats permanent x509 TLS trust failures
  as retryable; they fail fast instead of polling to the sync timeout (N2).
- Secret-store validation test uses Directory.CreateTempSubdirectory (N3).
- SealedSecret manifest requires the exact bitnami.com/v1alpha1 group/version
  instead of a bitnami.com/ prefix (N4).
- Embedded SealedSecret in last-applied-configuration is now validated
  recursively for plaintext spec.template.data/stringData (ASPIRERADIUS063) (N5).
- Recipe-parameter Merge validates all keys before applying (transactional) (N6).
- Deploy-parameters test now exercises the production WriteDeployParametersFile
  helper and asserts the owner-only ARM JSON file contract (N7).
- README secret-store diagnostics range lists only secret-store codes and notes
  056/057 are separate and 053/054/060 retired (N8).

Co-authored-by: Copilot <[email protected]>
Copilot-Session: b76dc20d-c553-47b7-8f5e-6fcdc0f10aa3

* Parse rad workspace config with YamlDotNet in SealedSecretApplyStep

The hand-rolled line/regex parser in ParseActiveWorkspaceContext did not
honor real YAML syntax, so valid rad configs (trailing inline comments on
values such as `default: prod # active`, quoted mapping keys, or flow-style
mappings) failed to resolve the active workspace context and aborted every
SealedSecret deployment with ASPIRERADIUS059 unless the override was set.

Parse ~/.rad/config.yaml with YamlDotNet (already a dependency), reading
workspaces.default then workspaces.items.<default>.connection.context, and
keep the fail-closed behavior for missing/ambiguous values (default present
but context missing -> null; no default -> single distinct context only).

Co-authored-by: Copilot <[email protected]>
Copilot-Session: b76dc20d-c553-47b7-8f5e-6fcdc0f10aa3

* Address PR review feedback on Radius secret stores

- SealedSecret apply: close TOCTOU by streaming the exact validated
  manifest bytes to `kubectl apply -f -` over stdin instead of
  re-reading the (mutable) manifest path.
- Reject uppercase inline secret-store names: the name is used verbatim
  as the backing Kubernetes Secret name (DNS-1123), so require lowercase
  to fail fast at the API/publish boundary instead of at deploy.
- ASPIRERADIUS067: include the 253-char limit and `.`/`..` prefix
  restrictions in the invalid-secret-data-key message.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: a79a2e75-6c34-40f1-8b75-dcd5ca8b2b16

* Address PR re-review on Radius sealed-secret deploy/publish

- SecretExistsAsync: treat transient connectivity/apiserver failures as
  "keep polling" (like the status probe) so a brief blip after
  Synced=True no longer aborts an otherwise healthy deploy. Refactored
  to an injectable overload and added unit coverage.
- RunKubectlAsync: stream stdin inside the same cancellation handler as
  WaitForExitAsync so a cancel while writing/flushing stdin terminates
  the kubectl process tree instead of leaking it.
- CopySealedSecretManifests: clear the integration-owned sealed-secrets
  subtree before writing so republishing after a store is removed or
  renamed no longer retains obsolete encrypted manifests.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: a79a2e75-6c34-40f1-8b75-dcd5ca8b2b16

* Validate spec.encryptedData in SealedSecret manifests

A SealedSecret with a missing, scalar, empty, or plaintext-looking
spec.encryptedData previously passed publish validation and was copied
verbatim into the artifact, even though that path promises a structurally
valid encrypted manifest.

Require spec to be a mapping containing a non-empty spec.encryptedData
mapping whose values are non-empty standard-base64 scalars, failing with
ASPIRERADIUS044. The gate runs after the existing plaintext and
last-applied-configuration leak checks so a leaking manifest still reports
the more specific ASPIRERADIUS063.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 8674d1f9-7353-40df-b64d-31803c6dbdd3

---------

Co-authored-by: Copilot <[email protected]>
Copilot-Session: f19583f4-384b-4601-a94b-290d9b0d4ed5
Copilot-Session: ddaf7f6d-b633-4b7e-9578-ec5b40e3c8e9
Copilot-Session: b76dc20d-c553-47b7-8f5e-6fcdc0f10aa3
Copilot-Session: a79a2e75-6c34-40f1-8b75-dcd5ca8b2b16
Copilot-Session: 8674d1f9-7353-40df-b64d-31803c6dbdd3
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 18, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-integrations Issues pertaining to Aspire Integrations packages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants