Skip to content

Add Radius recipe parameters and secret management - #18834

Merged
Mitch Denny (mitchdenny) merged 18 commits into
microsoft:mainfrom
nellshamrell:radius/pr2-recipes-and-secrets
Aug 10, 2026
Merged

Mitch Denny (mitchdenny) merged 18 commits into
microsoft:mainfrom
nellshamrell:radius/pr2-recipes-and-secrets

Conversation

@nellshamrell

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

Copy link
Copy Markdown
Contributor

Description

This adds recipe parameter customization and secret management to the Aspire.Hosting.Radius integration, so an AppHost can tune how Radius recipes provision backing resources and can supply the secrets those resources need — declaratively, in the app model — instead of configuring them out-of-band against the cluster.

What you can now do:

  • Pass recipe parameters to Radius recipes, either environment-wide or scoped to a specific Radius resource type, to control how backing resources are provisioned (region, SKU, etc.). Parameter values can be plain literals or late-bound ParameterResource / RadiusProviderReference values, including when nested inside objects/arrays.
  • Declare secret stores in the app model — application-scoped via builder.AddRadiusSecretStore(...) or environment-scoped via radius.WithSecretStore(...) — and populate them three ways: inline WithData, a reference to an existing Kubernetes Secret (WithExistingSecret), or an encrypted Bitnami SealedSecret manifest (WithSealedSecret) that is applied and its materialization awaited at deploy time.
  • Wire recipe configuration, environment secrets, and registry/Terraform authentication to declared stores.

Validation is fail-fast with a dedicated ASPIRERADIUS0xx diagnostic range covering population, publish, and deploy errors, so misconfiguration surfaces at publish time with an actionable message rather than as an opaque cluster failure.

User-facing usage

Recipe parameters (C# AppHost):

var radius = builder.AddRadiusEnvironment("radius")
    // Environment-wide parameters applied to every recipe.
    .WithRecipeParameters(p => p["region"] = "eastus")
    // Parameters scoped to a specific Radius resource type.
    .WithRecipeParameters("Radius.Data/redisCaches", p => p["sku"] = "Premium");

Secret stores (C# AppHost):

// Application-scoped store, inline data from secret parameters.
var dbUser = builder.AddParameter("db-user", secret: true);
var dbPassword = builder.AddParameter("db-password", secret: true);
builder.AddRadiusSecretStore("db-creds", RadiusSecretStoreType.BasicAuthentication)
    .WithData(d =>
    {
        d.Add("username", dbUser);
        d.Add("password", dbPassword);
    });

// Environment-scoped store backed by an existing Kubernetes Secret.
radius.WithSecretStore("tls-cert", RadiusSecretStoreType.Certificate, s =>
    s.WithExistingSecret("app/tls-cert", "tls.crt", "tls.key"));

// Environment-scoped store from an encrypted SealedSecret manifest,
// applied and awaited at deploy time.
radius.WithSecretStore("db-creds", RadiusSecretStoreType.BasicAuthentication, s =>
    s.WithSealedSecret("./secrets/db-creds.sealed.yaml", "username", "password"));

Security considerations

This change handles secret material and executes external tooling, so it is security-relevant:

  • No plaintext secrets in generated artifacts. Inline secret values are emitted into Bicep as references to valueless @secure() parameters, never as literals. SealedSecret manifests are validated to be a single encrypted Bitnami SealedSecret, and the parser fails closed if a manifest embeds a plaintext kind: Secret (including inside a last-applied-configuration annotation), has malformed/ambiguous structure, or uses YAML anchors/aliases/merge keys/duplicate keys (ASPIRERADIUS044, 063).
  • kubectl execution is injection-safe. All kubectl invocations use discrete ArgumentList argv entries with UseShellExecute=false; secret-returning calls suppress stdout logging so no secret material reaches logs, temp files, or error messages. The apply/sync/verify sequence is bounded by a materialization-timeout budget (ASPIRERADIUS066) and tolerates transient/NotFound poll failures rather than aborting the deploy.
  • Store names are validated against a strict grammar (ASCII letters/digits/hyphens, no .., no leading/trailing ., no Windows reserved device names) before being used as Bicep symbols and filesystem path segments, preventing path traversal.
  • Deploy fails closed when the active rad workspace's Kubernetes context cannot be resolved, rather than applying to kubectl's ambient context (ASPIRERADIUS059).

A security review of these changes was performed and found no high-confidence issues.

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 20, 2026 18:14
@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 -- 18834

Or

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

@github-actions github-actions Bot added the area-integrations Issues pertaining to Aspire Integrations packages label Jul 20, 2026

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

Adds publish/deploy-only secret-provider and recipe-configuration capabilities to the Radius deployment-target integration.

Changes:

  • Adds scoped recipe parameters with late-bound values.
  • Adds inline, existing, and sealed secret stores.
  • Adds validation, Bicep generation, deployment orchestration, documentation, and tests.

Reviewed changes

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

Show a summary per file
File Description
tests/.../SecretStoreValidationTests.cs Tests store validation diagnostics.
tests/.../SecretStoreDefaultPathTests.cs Tests default and Run-mode behavior.
tests/.../SecretStoreConsumerTests.cs Tests consumer annotations.
tests/.../SealedSecretManifestTests.cs Tests manifest security validation.
tests/.../SealedSecretArtifactTests.cs Tests artifact paths.
tests/.../SealedSecretApplyStepTests.cs Tests apply and synchronization logic.
tests/.../AddRadiusSecretStoreTests.cs Tests store APIs.
tests/.../WithRecipeParametersTests.cs Tests parameter registration.
tests/.../RecipeParameterIsolationAndFidelityTests.cs Tests environment isolation.
tests/.../RecipeParameterAdvancedTests.cs Tests nested and late-bound parameters.
tests/.../RecipePackParametersBicepTests.cs Tests recipe Bicep output.
tests/.../SecretStoreConsumerBicepTests.cs Tests consumer Bicep output.
tests/.../SealedSecretPublishTests.cs Tests sealed-secret publishing.
tests/.../RadiusDeployParametersTests.cs Tests deploy parameter bindings.
tests/.../InlineSecretStoreBicepTests.cs Tests inline-store output.
tests/.../ExistingSecretStoreBicepTests.cs Tests existing-secret output.
Secrets/SealedSecretManifest.cs Validates encrypted manifests.
Secrets/SealedSecretArtifact.cs Resolves artifact paths.
Secrets/RadiusSecretStoreValidation.cs Implements fail-fast validation.
Secrets/RadiusSecretStoreType.cs Defines store types and encodings.
Secrets/RadiusSecretStoreResource.cs Models secret stores.
Secrets/RadiusSecretStorePopulation.cs Models population modes.
Secrets/RadiusSecretStoreNaming.cs Validates store names.
Secrets/RadiusSecretStoreExtensions.cs Adds store builder APIs.
Secrets/RadiusSecretStoreConsumerExtensions.cs Adds consumer APIs.
Secrets/RadiusSecretStoreConsumer.cs Models consumer wiring.
Recipes/RadiusRecipeParameterExtensions.cs Adds recipe parameter APIs.
Recipes/RadiusProviderReference.cs Defines provider references.
README.md Documents new features.
RadiusEnvironmentResource.cs Adds validation/apply pipeline stages.
Publishing/RadiusInfrastructureOptions.cs Carries generated secret and parameter state.
Publishing/RadiusBicepPublishingContext.cs Copies sealed manifests.
Publishing/Constructs/RadiusSecretStoreConstruct.cs Models secret-store Bicep resources.
Publishing/BicepPostProcessor.cs Emits and validates new symbols.
CloudProviders/RadiusCloudProviderExtensions.cs Documents export suppression.
Aspire.Hosting.Radius.csproj Adds YamlDotNet.
Annotations/RadiusSecretStoresAnnotation.cs Stores consumer wiring.
Annotations/RadiusRecipeParametersAnnotation.cs Stores scoped recipe parameters.

Nell Shamrell-Harrington (nellshamrell) added a commit to nellshamrell/aspire that referenced this pull request Jul 20, 2026
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
Copilot AI review requested due to automatic review settings July 20, 2026 18:41
Nell Shamrell-Harrington (nellshamrell) added a commit to nellshamrell/aspire that referenced this pull request Jul 20, 2026
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

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 20, 2026 18:51

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 3 comments.

Comments suppressed due to low confidence (1)

src/Aspire.Hosting.Radius/Secrets/RadiusSecretStoreNaming.cs:69

  • Uppercase letters pass this check, but an inline store with no resource reference is materialized by Radius as a Kubernetes Secret whose metadata.name is the store name. Kubernetes object names reject uppercase, so names such as DbCreds pass AppHost validation and then fail only during deployment. Enforce the target-compatible lowercase DNS grammar, or separate the Aspire resource name from the physical secret-store/Secret name.
            else if (char.IsAsciiLetterOrDigit(c))

Nell Shamrell-Harrington (nellshamrell) added a commit to nellshamrell/aspire that referenced this pull request Jul 20, 2026
…e inline key rejection, existing-secret reference validation

Re-review of PR microsoft#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
Copilot AI review requested due to automatic review settings July 20, 2026 21:18

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 3 comments.

Nell Shamrell-Harrington (nellshamrell) added a commit to nellshamrell/aspire that referenced this pull request Jul 20, 2026
…ialization timeout, validate sealed manifest names

A second re-review round on PR microsoft#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
Copilot AI review requested due to automatic review settings July 20, 2026 21:39

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 42 out of 42 changed files in this pull request and generated 6 comments.

Comments suppressed due to low confidence (2)

src/Aspire.Hosting.Radius/Secrets/RadiusSecretStoreExtensions.cs:204

  • Resolve the manifest path before changing the population mode. Path.GetFullPath can throw for malformed paths; after that exception the resource remains marked as sealed and a corrected retry is rejected by ASPIRERADIUS065.
        population.HasSealedSecret = true;
        // Resolve a relative manifest path against the AppHost directory (not the process working
        // directory), matching other hosting file APIs (e.g. KeycloakResourceBuilderExtensions), so
        // the documented `./secrets/...` usage works regardless of where the AppHost is launched.
        population.SealedManifestPath = Path.GetFullPath(manifestPath, store.ApplicationBuilder.AppHostDirectory);
        population.Keys.AddRange(validatedKeys);

src/Aspire.Hosting.Radius/Secrets/RadiusSecretStoreNaming.cs:57

  • These rules allow uppercase letters and a 64-character name, but this value is also used as the name of a Radius-created Kubernetes Secret. Kubernetes object names must be lowercase DNS-1123 names, with each label limited to 63 characters, so accepted inputs such as DB-Creds or 64 as will fail only at deployment. Validate the physical store name against the Kubernetes naming contract (or map it to a separate valid physical name).
        if (!char.IsAsciiLetter(name[0]) || name[^1] == '-')
        {
            return false;
        }

@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.

Copilot AI review requested due to automatic review settings July 20, 2026 22:35
Nell Shamrell-Harrington (nellshamrell) added a commit to nellshamrell/aspire that referenced this pull request Jul 20, 2026
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
Nell Shamrell-Harrington (nellshamrell) added a commit to nellshamrell/aspire that referenced this pull request Jul 20, 2026
…e inline key rejection, existing-secret reference validation

Re-review of PR microsoft#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
Nell Shamrell-Harrington (nellshamrell) added a commit to nellshamrell/aspire that referenced this pull request Jul 20, 2026
…ialization timeout, validate sealed manifest names

A second re-review round on PR microsoft#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

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 42 out of 42 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (1)

src/Aspire.Hosting.Radius/Secrets/RadiusSecretStoreNaming.cs:28

  • Radius secret-store resource names are capped at 63 characters upstream, but this validator accepts 64. A 64-character name therefore passes AppHost validation and only fails when Radius processes the generated Applications.Core/secretStores resource, defeating the fail-fast guarantee. Align this limit, its diagnostic text, and the 64-character acceptance test with Radius's 63-character ResourceNameString contract.
    internal const int MaxNameLength = 64;

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
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
…e inline key rejection, existing-secret reference validation

Re-review of PR microsoft#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
…ialization timeout, validate sealed manifest names

A second re-review round on PR microsoft#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
- 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
- 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
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
- 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
- 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

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 43 out of 43 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (1)

src/Aspire.Hosting.Radius/Secrets/RadiusSecretStoreExtensions.cs:359

  • Radius does not accept the full Kubernetes Secret-name grammar here. Its fromResourceID path validates both segments with kubernetes.IsValidObjectName, which uses IsDNS1123Label; consequently accepted references such as app/db.creds (and names longer than 63 characters) are rejected by rad deploy. Validate the name as a DNS-1123 label as well so this API fails locally instead of emitting an unusable store.
        // The Secret name is a DNS-1123 subdomain; the namespace (when present) is a DNS-1123 label.
        // https://kubernetes.io/docs/concepts/overview/working-with-objects/names/
        if (!KubernetesName.IsDns1123Subdomain(name) || (ns is not null && !KubernetesName.IsDns1123Label(ns)))
        {
            throw new ArgumentException(
                $"Existing-secret reference '{namespaceAndName}' is invalid. The name must be a DNS-1123 subdomain and " +
                "the optional namespace a DNS-1123 label (lowercase alphanumeric, '-', with '.' allowed in the name). " +
                "Diagnostic: ASPIRERADIUS046.",

Copilot AI review requested due to automatic review settings July 27, 2026 18:55

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 43 out of 43 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

src/Aspire.Hosting.Radius/Publishing/SealedSecretApplyStep.cs:152

  • The final key-verification read is only timeout-bounded, not retried. After WaitForSealedSecretSyncedAsync observes the Secret, a transient/NotFound response from this immediately following kubectl get secret -o json aborts deployment, even though the preceding readiness probes retry the same failures within the materialization budget. Retry this verification query on IsTransientKubectlFailure/target NotFound until the shared deadline, while still failing permanent errors immediately.
            var dataKeys = await InvokeProbeWithRemainingBudgetAsync(
                ct => GetSecretDataKeysAsync(metadata.Namespace, metadata.Name, kubeContext, ct),
                RemainingBudget(deadline),
                cancellationToken,
                () => CreateOperationTimeoutException(store.Name, metadata.Namespace, metadata.Name, "verify", store.MaterializationTimeout))
                .ConfigureAwait(false);

@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.

Copilot AI review requested due to automatic review settings July 31, 2026 15:31

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 43 out of 43 changed files in this pull request and generated 1 comment.

@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.

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
Copilot AI review requested due to automatic review settings July 31, 2026 20:15

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 43 out of 43 changed files in this pull request and generated no new comments.

Suppressed comments (2)

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

  • This single example declares two Aspire resources named db-creds. Resource names are globally unique, so the second call throws instead of demonstrating the sealed-secret flow. Give the environment-scoped store a distinct Aspire name.
radius.WithSecretStore("db-creds", RadiusSecretStoreType.BasicAuthentication, s =>

tests/Aspire.Hosting.Radius.Tests/Publishing/SecretStoreConsumerBicepTests.cs:24

  • This model cannot pass the new validation gate: Terraform Git authentication requires the referenced store to declare a pat key, but this store only declares username and password. GenerateBicep is called directly here and bypasses pipeline validation, so the test currently verifies output that a real publish/deploy rejects with ASPIRERADIUS051. Add a secret PAT binding (or use a separate PAT store) so the test exercises a valid model.

@nellshamrell

Copy link
Copy Markdown
Contributor Author

Mitch Denny (@mitchdenny) anything I can do to help with review on this one?

@mitchdenny
Mitch Denny (mitchdenny) merged commit e407d5c into microsoft:main Aug 10, 2026
341 checks passed
@github-actions github-actions Bot added this to the 13.6 milestone Aug 10, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 10, 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.

3 participants