Skip to content

Project Radius backing resource connections from recipe outputs - #19031

Closed
Nell Shamrell-Harrington (nellshamrell) wants to merge 7 commits into
microsoft:mainfrom
nellshamrell:fix-radius-backing-resources
Closed

Nell Shamrell-Harrington (nellshamrell) wants to merge 7 commits into
microsoft:mainfrom
nellshamrell:fix-radius-backing-resources

Conversation

@nellshamrell

@nellshamrell Nell Shamrell-Harrington (nellshamrell) commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Description

An Aspire app deployed to Radius could not talk to its own cache, database, or queue. Every connection value the app received was wrong, so WithReference produced a connection string that pointed nowhere and the app failed at startup.

The cause is that a "backing" resource targeted at a Radius environment — Redis, PostgreSQL, MongoDB, SQL Server, RabbitMQ — is not deployed as a Radius.Compute/containers workload. It is provisioned by a Radius recipe. The recipe, not Aspire, decides the Kubernetes Service name and generates the credentials. Aspire was still deriving the host, port, and password from its own endpoint model, so it emitted a container-shaped address like cache-cache.default.svc.cluster.local for a Service the recipe had named something else, paired with a password the recipe never issued.

User-facing behavior

Referencing a backing resource now works. Every value a consumer sees is projected from that resource's own Radius outputs:

Value Projected from
Host / port, and anything composed from them (ConnectionStrings__*, *_HOST, *_PORT, *_URI, service discovery) <resource>.properties.host / <resource>.properties.port
Password, for resources emitted as legacy Applications.* types (Redis, MongoDB, RabbitMQ, SQL Server) <resource>.listSecrets().password
User name, for those same types <resource>.properties.username
Password and user name, for resources emitted as Radius.* types (PostgreSQL) Passed into the recipe on the resource type's required username / password schema properties, using the same secure Bicep parameter Aspire composes into the connection string, so both sides agree by construction

Because the substitution happens on the underlying values rather than on formatted strings, connection strings, URIs, and the individual properties emitted by WithReference all resolve consistently.

Three failures that were previously silent are now reported:

  • Referencing a backing resource in a different Radius environment fails with ASPIRERADIUS069 instead of emitting an unroutable address. This also surfaces from the Kubernetes, Azure Container Apps, and Azure App Service publishers, which resolve such references through the owning Radius environment.
  • A value that cannot be resolved at publish time — most commonly an Azure Bicep output — is logged at Warning. It was previously dropped at Debug, so every environment variable sourced from an Azure resource referenced by a Radius container silently disappeared from the published output.
  • A credential parameter the AppHost author supplied is reported when the recipe's generated credential replaces it, since the author's value never reaches the cluster.

User-facing usage

No API change is required — this is what an existing AppHost already looks like, and it now deploys correctly:

var builder = DistributedApplication.CreateBuilder(args);

var radius = builder.AddRadiusEnvironment("prod");

var cache = builder.AddRedis("cache");
var db = builder.AddPostgres("pg").AddDatabase("appdb");

builder.AddProject<Projects.Api>("api")
       .WithReference(cache)
       .WithReference(db);

builder.Build().Run();

aspire publish now emits, for the container:

ConnectionStrings__cache: {
  value: '${cache.properties.host}:${cache.properties.port},password=${cache.listSecrets().password}'
}
ConnectionStrings__appdb: {
  value: 'Host=${pg.properties.host};Port=${pg.properties.port};Username=postgres;Password=${pg_password};Database=appdb'
}

pg_password is the secure parameter Aspire also passes into the recipe, so the value the app receives and the value the recipe provisions are the same by construction. Where the same credential appears inside a URI it is escaped:

PG_URI: {
  value: 'postgresql://postgres:${uriComponent(pg_password)}@${pg.properties.host}:${pg.properties.port}/appdb'
}

The one new public API is the exception, so that a cross-environment reference can be caught by name:

try
{
    await app.RunAsync();
}
catch (RadiusBackingResourceEndpointException ex)
{
    Console.Error.WriteLine($"'{ex.Resource.Name}' is provisioned by a Radius recipe in " +
                            "another environment, so its address cannot be resolved here.");
}

Implementation notes

  • RadiusBackingConnections holds the type → connection-schema table. Its credential mode is a closed hierarchy (ListSecrets / RecipeInputProperties / NotProjected) so "credential handled by neither mechanism" — the exact shape of this bug — is unrepresentable, and a contract test fails if a newly mapped backing type has no schema entry.
  • The container environment-variable loop previously caught InvalidOperationException broadly. That was positional rather than structural; it is now narrowed to the conditions the publisher genuinely intends to skip, raised as an internal RadiusUnresolvableValueException. A value is only skipped when it is an IManifestExpressionProvider (a positive marker for "produced by another deployment") and it fails to resolve; an InvalidOperationException from any other value provider now fails the publish rather than silently dropping the variable.
  • Credentials for Radius.* types are written to the resource type's top-level schema properties rather than properties.recipe.parameters. The manifests in radius-project/resource-types-contrib declare username / password as required properties and the recipes read them as context.resource.properties.<name>, so the recipe-parameter shape would have failed schema validation at deploy time.
  • The default recipe for Radius.Data/postgreSqlDatabases is ghcr.io/radius-project/kube-recipes/postgresqldatabases:latest. The recipes/local-dev/postgresqldatabases artifact this originally pointed at is not published.
  • Values a ReferenceExpression marked as URI components are emitted as Bicep uriComponent(...), so a recipe-generated password containing @ or / cannot corrupt the URI it sits in.
  • The multi-database failure is scoped to databases consumers actually reference; unreferenced extras and servers with no database child warn and continue. Declaring several databases and referencing none of them fails too, rather than defaulting to the first: a database consumed only from inside a WithEnvironment callback records no reference annotation, so the choice cannot be proven.
  • SQL Server is emitted as the legacy Applications.Datastores/sqlDatabases type. The contrib UDT is Radius.Data/sqlServerDatabases (not sqlDatabases), and its Kubernetes recipe is not published — ghcr.io/radius-project/kube-recipes/sqlserverdatabases:latest returns 403 — so the legacy type, which has both a published recipe and a listSecrets() action, is the only deployable option today.
  • A credential parameter cannot serve two roles: using one parameter as both the user name and the password of a resource, or sharing it across resources when either credential is recipe-generated, fails with ASPIRERADIUS070. Substitutions are keyed by parameter identity, so such a parameter could only ever be rewritten to one of the two values.
  • New diagnostic codes ASPIRERADIUS069–074, documented in src/Aspire.Hosting.Radius/README.md along with three known gaps (default MongoDB/RabbitMQ user names cannot be projected, legacy rabbitMQQueues needs a queue property Aspire has no concept of, and uriComponent escaping differs cosmetically from Uri.EscapeDataString).

Validation

  • Aspire.Hosting.Radius.Tests: 500 passing, 0 failing (the count includes the secret-store tests that landed on main while this branch was open). The new tests cover schema totality, the cross-publisher exception contract, the narrowed-catch conditions (both the skip and the fail-the-publish path), user-name projection, database scoping, the credential warnings, and URI escaping.
  • A deployment end-to-end test, DeployRadiusPostgresBackingResourceToKind, stands up KinD plus the Radius control plane, publishes an AppHost that references a Postgres backing resource, deploys the generated artifacts, and then reads the environment back off the deployed container and authenticates against the provisioned database with psql. This is what surfaced the property-shape and recipe-source bugs above, which the Bicep snapshots could not catch.
    • Getting it to deploy at all exposed a platform gap worth calling out: rad install kubernetes registers only the built-in namespaces, and the Bicep extension rad resolves (br:biceptypes.azurecr.io/radius:<version>) does not carry Radius.Data/postgreSqlDatabases. The resource therefore compiles to a classic ARM resource (BCP081) and the deployment engine routes it to the Azure provider, failing with "Azure deployment failed, please ensure you have configured an Azure provider". The type has to be registered with the control plane (rad resource-type create) and published as a local Bicep extension (rad bicep publish-extension) that the app imports. The test does both, and the README now documents the sequence.
  • No behavior change in the publishers that share the endpoint resolver: Aspire.Hosting.Kubernetes.Tests 269/269, Aspire.Hosting.Azure.Kubernetes.Tests 63/63, Aspire.Hosting.Azure.Tests 1645 passed / 5 skipped.
  • ./build.sh clean with 0 warnings.
  • Every added or changed Verify snapshot was reviewed line by line rather than accepted on a green test, since this repo enables AutoVerify locally.

Security considerations

This change alters how credentials appear in generated deployment artifacts, so it is flagged for review even though the net effect is a reduction in exposure:

  • Aspire-generated password parameters for backing resources are no longer emitted into the published Bicep. Previously they were written as secure parameters that the recipe ignored, so the artifact carried credential material that had no deployment purpose.
  • Passwords are now read at deploy time via listSecrets(), or passed into the recipe as a secure parameter. No secret value is materialized into the generated file in either case.
  • Values interpolated into URIs are wrapped in uriComponent(...). Recipe-generated passwords come from an alphabet the recipe chooses rather than Aspire's URL-safe generator, so an unescaped @, /, or : could previously have re-parsed the URI's authority section.

Fixes #18935

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 balanced review requested due to automatic review settings August 5, 2026 21:46
@github-actions

github-actions Bot commented Aug 5, 2026

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 -- 19031

Or

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

@github-actions github-actions Bot added the area-integrations Issues pertaining to Aspire Integrations packages label Aug 5, 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

Routes Radius backing-resource connections through recipe outputs instead of invalid Aspire-derived endpoints.

Changes:

  • Projects host, port, username, and credentials from Radius resources.
  • Adds focused diagnostics, URI escaping, and a public cross-environment exception.
  • Expands unit and snapshot coverage across supported backing resources.

Reviewed changes

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

Show a summary per file
File Description
tests/Aspire.Hosting.Radius.Tests/Snapshots/LegacyFallbackEmissionTests.UdtOnly_DoesNotEmitLegacyParents.verified.bicep Captures UDT recipe credentials.
tests/Aspire.Hosting.Radius.Tests/Snapshots/LegacyFallbackEmissionTests.MixedLegacyAndUdt_EmitsBothParentPairs.verified.bicep Captures mixed resource credentials.
tests/Aspire.Hosting.Radius.Tests/Snapshots/LegacyFallbackEmissionTests.LegacyAndUdt_ShareResourceNameAndUseDistinctParents.verified.bicep Verifies distinct parent wiring.
tests/Aspire.Hosting.Radius.Tests/Snapshots/BackingResourceValueResolutionTests.UserNameParameter_IsProjectedFromRecipeOutputs.verified.bicep Verifies projected usernames.
tests/Aspire.Hosting.Radius.Tests/Snapshots/BackingResourceProjectionTests.LegacyBackingResource_DoesNotLeakAspireGeneratedPasswordParameter.verified.bicep Verifies secret replacement.
tests/Aspire.Hosting.Radius.Tests/Snapshots/BackingResourceProjectionTests.DirectEndpointPropertyReference_ProjectsRecipeOutputs.verified.bicep Verifies direct endpoint projection.
tests/Aspire.Hosting.Radius.Tests/Snapshots/BackingResourceProjectionTests.CallbackRenamingBackingResource_RewiresProjectedEnvironmentValues.verified.bicep Verifies callback rewiring.
tests/Aspire.Hosting.Radius.Tests/Snapshots/BackingResourceProjectionTests.AllBackingResourceTypes_ProjectRecipeOutputs.verified.bicep Covers all mapped backing types.
tests/Aspire.Hosting.Radius.Tests/RecordingLogger.cs Adds diagnostic log capture.
tests/Aspire.Hosting.Radius.Tests/Publishing/BackingResourceValueResolutionTests.cs Tests resolution and warning behavior.
tests/Aspire.Hosting.Radius.Tests/Publishing/BackingResourceProjectionTests.cs Tests projections and failure cases.
tests/Aspire.Hosting.Radius.Tests/Publishing/BackingResourceContractTests.cs Guards mapping/schema invariants.
src/Aspire.Hosting.Radius/ResourceMapping/ResourceTypeMapper.cs Exposes emitted backing-type mappings internally.
src/Aspire.Hosting.Radius/README.md Documents connection projection and diagnostics.
src/Aspire.Hosting.Radius/RadiusEnvironmentResource.cs Rejects unresolved backing endpoints.
src/Aspire.Hosting.Radius/RadiusBackingResourceEndpointException.cs Adds the public endpoint exception.
src/Aspire.Hosting.Radius/Publishing/RadiusUnresolvableValueException.cs Adds an internal skip condition.
src/Aspire.Hosting.Radius/Publishing/RadiusInfrastructureBuilder.cs Implements projection and credential wiring.
src/Aspire.Hosting.Radius/Publishing/RadiusBackingConnections.cs Defines per-type connection schemas.

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

github-actions Bot commented Aug 5, 2026

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

Suppressed comments (5)

src/Aspire.Hosting.Radius/Publishing/RadiusInfrastructureBuilder.cs:983

  • Passing the same parameter as both the user name and password of one legacy resource is not rejected because RegisterRecipeCredential permits repeated registration for the same owner. This assignment then overwrites the password substitution, so both fields resolve to properties.username and authentication fails. Track the credential role/accessor and reject one parameter mapping to two distinct recipe outputs, even for the same resource.
            WarnIfUserSuppliedCredentialIsReplaced(resource, userNameParameter, "user name");
            RegisterRecipeCredential(userNameParameter, resource, isProjectionSubstitution: true);
            _recipeSecretSubstitutions[userNameParameter] =
                new ProjectedValue(construct, userNameProperty, IsSecret: false, IsNumeric: false);

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

  • This diagnostic entry describes the unrelated-resource warning, but that warning does not include ASPIRERADIUS061; the code is only emitted when one parameter is shared by multiple backing-resource credentials. Document both behaviors accurately so users can map this code to the failure they receive.
| `ASPIRERADIUS061` | Publish | A resource references a parameter that is also a backing resource's credential. The recipe generates that credential, so the referencing resource receives the recipe's value rather than the parameter's. |

src/Aspire.Hosting.Radius/Publishing/Constructs/RadiusResourceTypeConstruct.cs:82

  • The PR description identifies the exception as the sole new public API, but this change also adds UserName, Password, and Database as public members on the callback construct. These become supported customization surface. Either include these members in the API review/description or keep them internal and drive them through the existing internal schema-property path.
    public BicepValue<object> UserName
    {
        get { Initialize(); return _userName!; }
        set { Initialize(); _userName!.Assign(value); }

src/Aspire.Hosting.Radius/RadiusBackingResourceEndpointException.cs:58

  • This public constructor throws when resource is null, but its XML documentation omits the exception contract. Document the ArgumentNullException so the published API docs match the implementation.
    /// <param name="resource">The backing resource whose address could not be determined.</param>
    /// <param name="message">The message that describes the error.</param>
    public RadiusBackingResourceEndpointException(IResource resource, string message)

src/Aspire.Hosting.Radius/Publishing/RadiusInfrastructureBuilder.cs:1012

  • Recipe-input user names are assigned here but are never registered with RegisterRecipeCredential. If one parameter is used for a legacy MongoDB/RabbitMQ user name and a PostgreSQL/SQL Server user name, the legacy substitution rewrites the UDT consumer to <legacy>.properties.username while this recipe still receives the original parameter, producing a credential mismatch. Register the resolved user-name parameter as a non-substitution owner too; note that PostgreSQL wraps it in a nested ReferenceExpression, so the current exact-provider helper does not find it.
        await SetTypePropertyAsync(construct, "username", withConnectionString, "username").ConfigureAwait(false);

@github-actions

github-actions Bot commented Aug 5, 2026

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.

@github-actions

github-actions Bot commented Aug 5, 2026

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.

@github-actions

github-actions Bot commented Aug 5, 2026

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 August 6, 2026 17:44

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Note

This error may be related to your runner configuration. You can now configure runners for Copilot code review separately from Copilot cloud agent by creating a copilot-code-review.yml file with your setup steps. Read the docs for details.

Fixes microsoft#18935.

`RadiusEnvironmentResource.GetHostAddressExpression` applied the Radius
container recipe's ClusterIP Service rule (`{name}-{name}.<ns>.svc.cluster.local`)
to every endpoint resolved for a Radius consumer. Backing resources (Redis,
PostgreSQL, MongoDB, SQL Server, RabbitMQ) are provisioned by a Radius *recipe*
rather than as a `Radius.Compute/containers` workload, and the recipe names its
own Service, so those addresses never resolved. Aspire also composed its own
locally-generated password parameters into the connection strings, which the
recipes never receive.

The blast radius was wider than the issue described: a single `WithReference`
emits both `ConnectionStrings__x` and the splatted `X_HOST`/`X_PORT`/
`X_PASSWORD`/`X_URI` connection properties, so guarding only the connection
string would have left most of them broken.

Substitute at the value-provider level instead, so connection strings, URIs,
splatted properties and `services__*` all compose correctly without this package
duplicating any connection-string format:

* host/port -> `<resource>.properties.host` / `.port`, wrapped in `string(...)`
  when standalone since the port output is an int and env values are strings.
* password on legacy `Applications.*` types -> `<resource>.listSecrets().password`.
* password/username/database on `Radius.*` UDTs -> passed into the recipe as
  `recipe.parameters`, so both sides agree by construction. These are required
  recipe inputs that were previously never emitted at all.

Fail fast rather than emit a silently unreachable value: backing-resource
endpoints resolved through the compute-environment helpers, references across
Radius environments, types with no host/port output, more than one database on a
server resource, and a credential parameter shared with a `listSecrets()` owner.
The new exception deliberately does not derive from `InvalidOperationException`
so the existing "skip unresolvable endpoint" catch cannot swallow it.

Projected values resolve their Bicep identifier lazily and are re-emitted after
`ConfigureRadiusInfrastructure` callbacks when a target was renamed, rejected
when it was removed, and left alone when the callback set the value itself.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 720998b6-ff9f-4ec9-9ad9-460909f7a186
Fixes the findings from the code-review, hosting-integration-authoring and
architecture reviews of the backing-resource projection change.

Error handling. The env-var loop's `catch (InvalidOperationException)` was
positional rather than structural: it silently dropped every value produced
by an Azure Bicep output, at Debug level, because that is the type
`BicepOutputReference.Value` happens to throw. The two conditions the
publisher genuinely means to skip -- a value only knowable after another
deployment, and a reference to an endpoint the target does not declare --
are now raised as `RadiusUnresolvableValueException` and logged at Warning;
everything else fails the publish.

Exception contract. `RadiusBackingResourceEndpointException` is now public
and lives in `Aspire.Hosting.Radius`, because it reaches authors using the
Kubernetes, Container Apps and App Service publishers through the shared
endpoint resolver. Its message is written for that audience.

Schema table. The `(string? PasswordSecret, bool TakesCredentialRecipeParameters)`
pair could express "credential handled by neither mechanism" -- the shape of
the bug this change fixes -- so it is replaced by a closed credential mode.
Radius types with no verified schema are removed rather than left to project
values that may not exist, and a test fails if an emitted type has no entry.

Credentials. A user name supplied as a parameter is now projected from the
recipe's output like the password already was, so the connection string no
longer names a user the recipe never created. Replacing a credential the
AppHost author chose is reported, since its value never reaches the cluster.

Databases. The multi-database failure is scoped to databases consumers
actually reference; a server with no database child publishes with a warning.
Recipe inputs are resolved through a substitution-free path so a recipe
cannot be fed its own output, and are rebuilt when a
`ConfigureRadiusInfrastructure` callback swaps the construct they target.

URI escaping. Values a reference expression marked as URI components are
emitted as `uriComponent(...)`, so a recipe-generated password containing
`@` or `/` cannot corrupt the URI it is placed in.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: b3bee2e4-d5fd-4325-a4e7-090e4598c5e1
The exception is the one piece of public API this change introduces, and
catching it is the whole reason it is public, so show that.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: b3bee2e4-d5fd-4325-a4e7-090e4598c5e1
Address the second round of review feedback on the Radius backing
resource projection:

- Credentials for Radius.* resource types are now written to the
  required top-level schema properties (username/password/database)
  instead of properties.recipe.parameters. The resource type manifests
  in radius-project/resource-types-contrib declare these as required
  properties and the recipes read them via
  context.resource.properties.<name>, so the previous shape would have
  failed schema validation at deploy time.
- Point Radius.Data/postgreSqlDatabases at
  ghcr.io/radius-project/kube-recipes/postgresqldatabases:latest. The
  recipes/local-dev/postgresqldatabases artifact is not published.
- Only skip an environment variable when the failing value provider is
  an IManifestExpressionProvider, so an InvalidOperationException from
  an arbitrary provider fails the publish instead of silently dropping
  the variable.
- Add a KinD deployment end-to-end test that deploys a Radius Postgres
  backing resource and verifies the projected connection information.
- Fix stale test class and method references in docs, and scope the
  README credential-replacement warning to legacy Applications.*
  resources.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 62ae7028-e315-4b1d-9d85-e7b58bc1e1f0
rad install kubernetes registers only the built-in namespaces, and the
pinned bicep extension does not carry Radius.Data/postgreSqlDatabases, so
the resource compiled to a classic ARM resource and the deployment engine
routed it to the Azure provider. Register the type with the control plane
and import a locally published extension so the type is deployable, then
deploy the published artifacts directly and assert the password projected
into the consumer both matches the parameter and authenticates.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 62ae7028-e315-4b1d-9d85-e7b58bc1e1f0
- Map SqlServerServerResource to the legacy Applications.Datastores/sqlDatabases
  type with a listSecrets() projection. Radius.Data/sqlDatabases is not a real
  UDT (contrib defines Radius.Data/sqlServerDatabases) and its kube recipe is
  not published, so the emitted type could not resolve at deploy time.
- Reject a parameter used as both the user name and the password of one backing
  resource. Substitutions are keyed by parameter identity, so the later user
  name assignment silently overwrote the password projection.
- Register user-name parameters as recipe credentials on the schema-property
  path so sharing one with a listSecrets()-substituted resource is caught, and
  unwrap nested pass-through ReferenceExpressions when extracting a credential
  parameter (PostgreSQL exposes its user name that way).
- Fail the publish when several databases are declared and none is referenced
  through WithReference, instead of picking the first child; a WithEnvironment
  callback consumer records no annotation, so the choice cannot be proven.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: d532fd9b-ea31-4f3e-afa0-2511df99b0ba
The secret-store work that landed on main claimed ASPIRERADIUS061-068, which
collided with the 060-065 range this branch used for backing-resource
projection. Move the backing-resource codes to the free 069-074 range so each
diagnostic still identifies exactly one condition.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: d532fd9b-ea31-4f3e-afa0-2511df99b0ba

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

Suppressed comments (1)

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

  • This is not a current limitation: the upstream TypeSpec declares queue as optional, and the default recipe uses context.resource.name when it is omitted. Keeping this bullet incorrectly tells users that generated RabbitMQ resources fail schema validation; please remove it.
* Legacy `Applications.Messaging/rabbitMQQueues` requires a `queue` property that Aspire does not emit, because the Aspire RabbitMQ resource has no queue concept.

Comment on lines +133 to +134
[RadiusResourceTypes.LegacySqlDatabases] =
new("server", "port", "username", new RadiusCredentialMode.ListSecrets("password")),
@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

Closing in favor of #19253, opened from an identical branch (88d96d3f5) pushed directly to microsoft/aspire instead of my fork. No code changes — same commit, same review history captured there.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Code review — 7 findings

Reviewed the full change set against the upstream merge base. Important: the pushed PR head (88d96d3f5) is 10 commits behind the branch in the author's fork (3eebff33d), so several findings below refer to code that only exists locally and could not be anchored as inline comments. All 590 Aspire.Hosting.Radius.Tests pass locally on the newer commit.

Categories: 1 process/blocking, 2 test-infrastructure, 1 correctness, 1 API-review, 2 docs/convention.


1. The PR head is 10 commits stale — the pushed diff is not what would be merged (blocking for review)

PR head is 88d96d3f5; the branch is at 3eebff33d. The pushed version still contains RadiusBackingResourceEndpointException (renamed to RadiusBackingResourceProjectionException locally), the old WarnOnUnrelatedUsesOfSubstitutedParameters double-negation, and none of the ASPIRERADIUS075–ASPIRERADIUS090 diagnostics. Please push 3eebff33d before further review — inline comments can only anchor to lines present in the pushed diff.

2. Two new heavyweight KinD deployment E2E tests run on every PR as plain [Fact]

RadiusDeployTests.DeployRadiusPostgresBackingResourceToKind and (in the newer commits) DeployRadiusRedisRabbitMqAndMongoBackingResourcesToKind each create a KinD cluster, install the Radius control plane, run aspire deploy with a 20-minute budget, two 6-minute kubectl waits, and 8-minute retry loops. Together with the pre-existing DeployRadiusContainerToKind that is three full KinD + Radius control-plane installs per PR run of the CLI E2E suite — worst case well over an hour of wall clock and three new flake surfaces (image pulls, control-plane install, recipe pulls from ghcr).

The coverage itself is genuinely good and worth keeping; the concern is only the per-PR budget. Consider [OuterloopTest] for at least the multi-resource test, or consolidating the three into a single cluster lifecycle.

3. Radius v0.59 → v0.60 is a silent breaking change with no release note

README.md now requires Radius v0.60+ and documents that v0.59 fails silently: v0.60 renamed the Radius.Core/recipePacks fields recipeKind/recipeLocation to kind/source, and the Radius API server drops unrecognized fields rather than rejecting them, so a v0.59 cluster produces an empty recipe pack with no error and every backing resource then fails to resolve a recipe.

Anyone already on v0.59 who takes this package upgrade gets a deploy that reports success and produces a non-functional app. The README explains it well, but there is no breaking-change entry or release note accompanying the change, and nothing in the emitted artifacts detects or asserts the control-plane version.

4. The RabbitMQ guest guard only catches the literal default

In RadiusInfrastructureBuilder.ApplyRecipeInputPropertyCredentialsAsync (local RadiusInfrastructureBuilder.cs:2373-2374):

if (construct.GetSchemaProperty("username") is { } emittedUserName &&
    RenderBicepValue(emittedUserName) is "'guest'")

RenderBicepValue returns a quoted Bicep string literal only when the user name was a literal. AddRabbitMQ("q", userName: builder.AddParameter("u")) renders as a Bicep identifier (u), so a parameter whose value happens to be guest sails through the guard and provisions a broker that RabbitMQ restricts to loopback — no workload can authenticate against it, which is exactly the failure ASPIRERADIUS082 exists to prevent.

Note that supplying a parameter is precisely the remediation the ASPIRERADIUS082 message recommends, so the guidance routes users around the guard. Parameter values are generally resolvable at publish time; consider resolving the parameter's value before comparing, so both spellings are covered.

5. New public API added without API review

RadiusBackingResourceEndpointException / RadiusBackingResourceProjectionException is a new public type on a shipping surface, and the PR checklist answers "No" to API review. Worth an explicit API review sign-off before merge, especially since the type was renamed after the pushed head — the PR description still names the old type.

6. Assert.DoesNotContain in the new deployment E2E assertions (newer commits)

tests/Aspire.Cli.EndToEnd.Tests/RadiusDeployTests.cs (local lines 624-625, 632) asserts the legacy Redis/RabbitMQ/Mongo type strings are absent from the generated Bicep. The repository test guidelines explicitly discourage Assert.DoesNotContain as a weak assertion that easily goes out of date. The positive assertions two lines above (Assert.Contains("Radius.Data/redisCaches", ...), Assert.Contains("Radius.Messaging/rabbitMQ@", ...)) already establish the emitted type, making these redundant — prefer asserting the complete emitted type set instead.

7. Stale class-level documentation in RadiusDeployTests

The class summary states "A public image (mcr.microsoft.com/dotnet/samples:aspnetapp) is used so the KinD node pulls it directly from MCR", but ContainerImage is mcr.microsoft.com/azuredocs/aci-helloworld. Pre-existing, but this PR adds two more tests that inherit that documentation, so it is a good opportunity to correct it.


Verified and cleared (no action needed)

  • The Redis NoCredential path emits '${cache.properties.host}:${cache.properties.port},password='. Confirmed empirically that StackExchange.Redis.ConfigurationOptions.Parse normalizes the empty password away entirely (round-trips to host:6379), so no AUTH is attempted against the unauthenticated recipe-deployed server.
  • The ASPIRERADIUS071 hard failure for an emitted backing type with no schema row is correctly justified and pinned by EveryEmittedBackingType_HasAConnectionSchema.
  • EnvPart.WithStringFormat / ApplyStringFormat stay in sync with Aspire.Hosting.Utils.FormattingHelpers.FormatValue (both uri-only, both case-insensitive).
  • Narrowing catch (InvalidOperationException) to RadiusUnresolvableValueException is correctly gated on a positive IManifestExpressionProvider marker with a cycle-safe, fail-closed walk.
  • Deployment E2E coverage genuinely authenticates against the deployed servers rather than asserting on generated Bicep: psql -tAc 'select 1' for PostgreSQL, rabbitmqctl authenticate_user for RabbitMQ, mongosh --authenticationDatabase admin for MongoDB, and redis-cli ping to prove Redis is unauthenticated. This is the right shape for the change.

@nellshamrell

Copy link
Copy Markdown
Contributor Author

Retracting my earlier review on this PR — I posted it here by mistake. This PR is closed and superseded; the live PR for this work is #19555, where the review has been reposted against the current head.

The two inline comments have been deleted. The review body above cannot be removed via the API on a submitted review, so please disregard it — in particular its first finding, which misdiagnosed a stale head that was simply the result of this PR being closed while the branch continued to move.

@github-actions github-actions Bot locked and limited conversation to collaborators Sep 24, 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.

Radius: backing resources (Redis/Postgres/Mongo/etc.) emit {name}-{name} service discovery that doesn't match the recipe's Service

3 participants