Skip to content

Show resources waiting for parameters during startup - #22291

Draft
James Newton-King (JamesNK) wants to merge 9 commits into
mainfrom
jamesnk/contextual-parameter-waits
Draft

James Newton-King (JamesNK) wants to merge 9 commits into
mainfrom
jamesnk/contextual-parameter-waits

Conversation

@JamesNK

@JamesNK James Newton-King (JamesNK) commented Nov 14, 2026 •

Copy link
Copy Markdown
Member

Description

Resources blocked on missing parameter values now show Unresolved parameters and identify the parameters they are actually waiting for, instead of appearing stuck during startup. The list updates as values become available, including when a read happens before the resource reaches Starting.

This is an independently implemented alternative to #18896, based on main. It observes incomplete ParameterResource.GetValueAsync(ValueProviderContext, CancellationToken) calls and attributes them to ValueProviderContext.Caller; it does not predict dependencies by walking the resource model.

Behavior and implementation

  • Reference-count concurrent reads per caller instance so completing or canceling one read cannot clear another active wait. Only parameters actually read are reported, including reads inside opaque callbacks and conditional expressions.
  • Restore the previous startup state, including an unset state, after the last read finishes without overwriting newer lifecycle updates or replacing an active dependency wait.
  • Treat unresolved-parameter waits as startup for Start, Stop, and Restart command availability.
  • Forward value-provider context through startup configuration, connection strings and properties, Dockerfile arguments and secrets, certificate passwords, URL expressions, and integration configuration callbacks.
  • Add IResourceWithConnectionString.GetConnectionStringAsync(ValueProviderContext, CancellationToken). Its default implementation calls the existing context-free resolver for compatibility with custom resources whose runtime connection string differs from their expression.
  • Have built-in connection-string resources explicitly forward context, including parent/child resources, connection-string parameters, and redirects. Third-party resolvers can opt in by implementing the contextual overload.
  • Resolve connection strings contextually in dashboard publication and the early PostgreSQL, Redis, and SQL Server callbacks. Missing passwords are attributed before those callbacks block startup; the existing event ordering is unchanged.
  • Keep localhost networking for dashboard display values and host-side integration clients, independently of the caller used for parameter attribution.
  • Track parameter names, not values. Context-free reads and publish-mode reporting retain their existing behavior. No dependencies are added or updated.

User-facing usage

No extra configuration is required for ordinary parameter references:

var password = builder.AddParameter("postgres-password", secret: true);
var postgres = builder.AddPostgres("postgres", password: password);

While postgres-password is missing, postgres reports KnownResourceStates.UnresolvedParameters and the dashboard identifies the missing parameter. Supplying the value allows startup to continue.

Custom startup callbacks and nested value providers get the same attribution by forwarding a ValueProviderContext containing the execution context and requesting resource to GetValueAsync.

Custom connection-string resources can implement the new contextual overload:

public ValueTask<string?> GetConnectionStringAsync(
    ValueProviderContext context,
    CancellationToken cancellationToken) =>
    ConnectionStringExpression.GetValueAsync(context, cancellationToken);

Resolvers with custom runtime behavior should retain that behavior and forward the context to any nested value providers. Existing implementations that only provide GetConnectionStringAsync(CancellationToken) continue to work, but do not gain contextual parameter attribution automatically.

Screenshots / Recordings

The branch-built dashboard showing parameter reads made inside an opaque environment callback:

Resource waiting for api-key and region

Validation

739 targeted tests passed on the current changes. Quarantined and outerloop tests were excluded.

Command Result
dotnet test --project tests\Aspire.Hosting.Tests\Aspire.Hosting.Tests.csproj --no-launch-profile -- --filter-class '*.AddParameterTests' --filter-class '*.AddConnectionStringTests' --filter-class '*.ResourceNotificationTests' --filter-class '*.ApplicationOrchestratorTests' --filter-class '*.ExpressionResolverTests' --filter-class '*.ConditionalReferenceExpressionTests' --filter-class '*.WithReferenceTests' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true' Passed: 418
dotnet test --project tests\Aspire.Hosting.Tests\Aspire.Hosting.Tests.csproj --no-launch-profile -- --filter-class '*.ResourceCommandAnnotationTests' --filter-class '*.WithUrlsTests' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true' Passed: 136
dotnet test --project tests\Aspire.Hosting.PostgreSQL.Tests\Aspire.Hosting.PostgreSQL.Tests.csproj --no-launch-profile -- --filter-class '*.AddPostgresTests' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true' Passed: 55
dotnet test --project tests\Aspire.Hosting.Redis.Tests\Aspire.Hosting.Redis.Tests.csproj --no-launch-profile -- --filter-class '*.AddRedisTests' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true' Passed: 54
dotnet test --project tests\Aspire.Hosting.SqlServer.Tests\Aspire.Hosting.SqlServer.Tests.csproj --no-launch-profile -- --filter-class '*.AddSqlServerTests' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true' Passed: 15
dotnet test --project tests\Aspire.Hosting.Azure.Tests\Aspire.Hosting.Azure.Tests.csproj --no-launch-profile -- --filter-class '*.AzureKeyVaultTests' --filter-class '*.AzureKeyVaultConnectionPropertiesTests' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true' Passed: 41
dotnet test --project tests\Aspire.Dashboard.Tests\Aspire.Dashboard.Tests.csproj --no-launch-profile -- --filter-class '*.ResourceStateViewModelTests' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true' Passed: 20
git diff --cached --check Passed

All 33 affected Hosting projects were also compiled together using a temporary validation solution, which was removed afterward. The build succeeded with an existing MySqlConnector vulnerability warning; dashboard validation also reported an existing Microsoft.Extensions.Validation advisory.

Regression coverage includes the real pre-start connection-string event sequence, missing database passwords, legacy custom resolvers with unused unresolved expressions, contextual redirects, caller attribution, concurrent reads, cancellation/failure, lifecycle-state restoration, and localhost display values.

Earlier manual validation built and started an isolated, no-container AppHost using the branch's Hosting and Dashboard builds. Ordinary environment references and an opaque callback reported their actual pending parameters. Supplying api-key reduced the callback's list from api-key, region to region; supplying region let both executables finish successfully with exit code 0. The demo was stopped and removed.

The full test suite was not run.

Fixes # (issue)

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

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@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 -- 22291

Or

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

@github-actions

This comment has been minimized.

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.

🟡 Changes recommended

Outstanding endpoint-resolution and startup-state bugs can produce host-inaccessible dashboard URLs, suppress missing-parameter reporting, and enable Stop/Restart commands that remain pending.

4 open issues
1 file not reviewed
  • src/Aspire.Dashboard/Resources/Columns.Designer.cs: Generated file
What changed in this PR

This PR adds runtime tracking of unresolved parameter reads so Aspire can identify which parameters are blocking resource startup. Unlike the relationship-based approach in #18896, it follows actual value resolution, including callbacks that forward caller context.

Changes:

  • Tracks concurrent parameter waits and restores prior startup states as reads complete.
  • Propagates caller context through value providers and integration configuration.
  • Adds dashboard warning details, localization resources, and focused regression tests.
File Description
tests/​Aspire.Hosting.Tests/​AddParameterTests.cs Tests wait tracking, cleanup, state preservation, and caller attribution.
tests/​Aspire.Dashboard.Tests/​Model/​ResourceStateViewModelTests.cs Tests parameter tooltip and warning presentation.
src/​Shared/​Model/​KnownProperties.cs Defines unresolved-parameter metadata key.
src/​Aspire.Hosting/​ResourceBuilderExtensions.cs Forwards caller context through parameter and URL reads.
src/​Aspire.Hosting/​Orchestrator/​ApplicationOrchestrator.cs Adds context to connection detail resolution.
src/​Aspire.Hosting/​ExternalServiceBuilderExtensions.cs Attributes external-service parameter waits.
src/​Aspire.Hosting/​Dcp/​ContainerCreator.cs Adds context to Dockerfile argument and secret resolution.
src/​Aspire.Hosting/​ApplicationModel/​ResourceUrlsEditor.cs Carries caller context through polyglot URL expressions.
src/​Aspire.Hosting/​ApplicationModel/​ResourceUrlsCallbackContext.cs Passes the resource to the URL editor.
src/​Aspire.Hosting/​ApplicationModel/​ResourceNotificationService.cs Counts parameter waits and updates resource snapshots.
src/​Aspire.Hosting/​ApplicationModel/​ParameterResource.cs Reports incomplete contextual parameter reads.
src/​Aspire.Hosting/​ApplicationModel/​KnownResourceStates.cs Defines the unresolved-parameters state.
src/​Aspire.Hosting/​ApplicationModel/​IValueProvider.cs Documents context forwarding and caller attribution.
src/​Aspire.Hosting/​ApplicationModel/​HttpsCertificateExecutionConfigurationGatherer.cs Preserves context for certificate value resolution.
src/​Aspire.Hosting.Redis/​RedisBuilderExtensions.cs Attributes Redis Commander password reads.
src/​Aspire.Hosting.PostgreSQL/​PostgresBuilderExtensions.cs Attributes pgAdmin and pgWeb configuration reads.
src/​Aspire.Hosting.OpenAI/​OpenAIExtensions.cs Attributes initialization-time parameter reads.
src/​Aspire.Hosting.MySql/​MySqlBuilderExtensions.cs Attributes phpMyAdmin password reads.
src/​Aspire.Hosting.MongoDB/​MongoDBBuilderExtensions.cs Attributes key-file value resolution.
src/​Aspire.Dashboard/​Resources/​xlf/​Columns.zh-Hant.xlf Adds pending Traditional Chinese tooltip translation entry.
src/​Aspire.Dashboard/​Resources/​xlf/​Columns.zh-Hans.xlf Adds pending Simplified Chinese tooltip translation entry.
src/​Aspire.Dashboard/​Resources/​xlf/​Columns.tr.xlf Adds pending Turkish tooltip translation entry.
src/​Aspire.Dashboard/​Resources/​xlf/​Columns.ru.xlf Adds pending Russian tooltip translation entry.
src/​Aspire.Dashboard/​Resources/​xlf/​Columns.pt-BR.xlf Adds pending Brazilian Portuguese tooltip translation entry.
src/​Aspire.Dashboard/​Resources/​xlf/​Columns.pl.xlf Adds pending Polish tooltip translation entry.
src/​Aspire.Dashboard/​Resources/​xlf/​Columns.ko.xlf Adds pending Korean tooltip translation entry.
src/​Aspire.Dashboard/​Resources/​xlf/​Columns.ja.xlf Adds pending Japanese tooltip translation entry.
src/​Aspire.Dashboard/​Resources/​xlf/​Columns.it.xlf Adds pending Italian tooltip translation entry.
src/​Aspire.Dashboard/​Resources/​xlf/​Columns.fr.xlf Adds pending French tooltip translation entry.
src/​Aspire.Dashboard/​Resources/​xlf/​Columns.es.xlf Adds pending Spanish tooltip translation entry.
src/​Aspire.Dashboard/​Resources/​xlf/​Columns.de.xlf Adds pending German tooltip translation entry.
src/​Aspire.Dashboard/​Resources/​xlf/​Columns.cs.xlf Adds pending Czech tooltip translation entry.
src/​Aspire.Dashboard/​Resources/​Columns.resx Adds parameter-wait tooltip text.
src/​Aspire.Dashboard/​Resources/​Columns.Designer.cs Exposes the tooltip resource accessor.
src/​Aspire.Dashboard/​Model/​ResourceViewModelExtensions.cs Reads unresolved parameter names from metadata.
src/​Aspire.Dashboard/​Model/​ResourceStateViewModel.cs Displays warning icon and parameter details.
src/​Aspire.Dashboard/​Model/​KnownResourceState.cs Recognizes the new dashboard state.
src/​Aspire.Dashboard/​Extensions/​ResourceViewModelExtensions.cs Classifies parameter waits as unusable transitory states.
src/​Aspire.Dashboard/​Components/​Layout/​ResourcesLayout.razor.cs Applies warning styling to parameter waits.

Review effort: Balanced

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

This comment has been minimized.

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.

🟡 Changes recommended

Active issues break host-facing endpoint resolution, obscure unresolved parameters after dependency waits, and enable Stop/Restart commands that can hang during startup.

4 open issues
1 previously missed issue

In code that hasn't changed since last review

Medium severity Resolve host-facing container URLs on the localhost network

src/​Aspire.Hosting/​ResourceBuilderExtensions.cs:2460

Adding Caller without Network makes container endpoint expressions resolve to container DNS names and target ports, so dashboard links become inaccessible from the host browser and published connection properties disagree with the host-facing connection string. Keep caller attribution but explicitly set Network = KnownNetworkIdentifiers.LocalhostNetwork for these host-facing resolutions. Apply the same fix in src/Aspire.Hosting/ApplicationModel/ResourceUrlsEditor.cs:15 and src/Aspire.Hosting/Orchestrator/ApplicationOrchestrator.cs:89.

1 resolved since last review
1 file not reviewed
  • src/Aspire.Dashboard/Resources/Columns.Designer.cs: Generated file

Review effort: Balanced

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@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.

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

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

This comment has been minimized.

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.

🔵 Needs a closer look

Startup can still block on untracked connection-string reads, while build-argument resolution changes existing values and wait-state handling can hide unresolved parameters and dependency controls.

3 open issues
3 previously missed issues

In code that hasn't changed since last review

Medium severity Allow unresolved-parameter resources to enter dependency waiting

src/​Aspire.Hosting/​ApplicationModel/​ResourceNotificationService.cs:1097

If a parameter read changes Starting to UnresolvedParameters before dependency waiting begins, CanTransitionToWaiting rejects the new state, so dependency details and the force-start command remain unavailable. Add state == KnownResourceStates.UnresolvedParameters to CanTransitionToWaiting at line 670, and cover a parameter read that begins before dependency waiting is entered.

Medium severity Keep build-argument endpoint resolution on the localhost network

src/​Aspire.Hosting/​Dcp/​ContainerCreator.cs:620

Adding Caller without specifying Network also changes existing build-argument resolution: GetNetworkIdentifier() now selects the container network instead of localhost. For example, an endpoint supplied as a build argument for a browser-facing API URL changes from http://localhost:<host-port> to a Docker-only hostname and target port, leaving the generated frontend pointing at an unreachable address. Set the network explicitly to LocalhostNetwork here to preserve the previous resolution behavior while adding wait attribution.

Medium severity Preserve custom connection-string resolution for contextual build args

src/​Aspire.Hosting/​Dcp/​ContainerCreator.cs:627

When an IResourceWithConnectionString is passed through WithBuildArg(string, object), the contextual overload resolves ConnectionStringExpression instead of calling its custom GetConnectionStringAsync, potentially supplying a different build value. Preserve custom connection-string resolution while adding caller attribution, and add a regression test where the custom resolver returns a different value from the expression.

1 resolved since last review
1 file not reviewed
  • src/Aspire.Dashboard/Resources/Columns.Designer.cs: Generated file

Review effort: Balanced

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

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@aspire-repo-bot
aspire-repo-bot Bot requested a balanced review from Copilot November 15, 2026 08:45
@aspire-repo-bot
aspire-repo-bot Bot requested a balanced review from Copilot November 15, 2026 11:43
@JamesNK James Newton-King (JamesNK) changed the title Track resource parameter waits through value provider contexts Show resources waiting for parameters during startup Nov 15, 2026
@github-actions

This comment has been minimized.

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.

🟡 Changes recommended

Contextual connection-string reads now lose the supplied caller and network for expression-only third-party resources, potentially returning localhost and mapped ports instead of container-network addresses.

2 open issues
1 resolved since last review
1 file not reviewed
  • src/Aspire.Dashboard/Resources/Columns.Designer.cs: Generated file

Review effort: Balanced

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

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

This comment has been minimized.

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.

🟡 Changes recommended

Setting Caller without retaining the localhost network changes build-argument endpoint resolution, potentially embedding container-only URLs that browsers cannot reach into frontend builds.

1 open issue
2 resolved since last review
1 file not reviewed
  • src/Aspire.Dashboard/Resources/Columns.Designer.cs: Generated file

Review effort: Balanced

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor

Tests selector

56 / 101 PR test projects · 5 PR jobs, from 115 changed files.

Selected PR test projects (56 / 101)

Aspire.Cli.EndToEnd.Tests, Aspire.Cli.Tests, Aspire.Dashboard.Components.Tests, Aspire.Dashboard.Tests, Aspire.Hosting.Analyzers.Tests, Aspire.Hosting.Azure.EntraId.Tests, Aspire.Hosting.Azure.Kubernetes.Tests, Aspire.Hosting.Azure.Kusto.Tests, Aspire.Hosting.Azure.Provisioning.Tests, Aspire.Hosting.Azure.Tests, Aspire.Hosting.Blazor.Tests, Aspire.Hosting.Browsers.Tests, Aspire.Hosting.CodeGeneration.Go.Tests, Aspire.Hosting.CodeGeneration.Java.Tests, Aspire.Hosting.CodeGeneration.Python.Tests, Aspire.Hosting.CodeGeneration.Rust.Tests, Aspire.Hosting.CodeGeneration.TypeScript.Tests, Aspire.Hosting.Containers.Tests, Aspire.Hosting.DevTunnels.Tests, Aspire.Hosting.Docker.Tests, Aspire.Hosting.Dotnet.Tests, Aspire.Hosting.DotnetTool.Tests, Aspire.Hosting.EntityFrameworkCore.Tests, Aspire.Hosting.Foundry.Tests, Aspire.Hosting.Garnet.Tests, Aspire.Hosting.Go.Tests, Aspire.Hosting.Java.Tests, Aspire.Hosting.JavaScript.Tests, Aspire.Hosting.Kafka.Tests, Aspire.Hosting.Keycloak.Tests, Aspire.Hosting.Kubernetes.Tests, Aspire.Hosting.Maui.Tests, Aspire.Hosting.Milvus.Tests, Aspire.Hosting.MongoDB.Tests, Aspire.Hosting.MySql.Tests, Aspire.Hosting.Nats.Tests, Aspire.Hosting.OpenAI.Tests, Aspire.Hosting.Oracle.Tests, Aspire.Hosting.Orleans.Tests, Aspire.Hosting.PostgreSQL.Tests, Aspire.Hosting.Python.Tests, Aspire.Hosting.Qdrant.Tests, Aspire.Hosting.RabbitMQ.Tests, Aspire.Hosting.Radius.Tests, Aspire.Hosting.Redis.Tests, Aspire.Hosting.RemoteHost.Tests, Aspire.Hosting.Rust.Tests, Aspire.Hosting.Seq.Tests, Aspire.Hosting.SqlServer.Tests, Aspire.Hosting.Testing.Tests, Aspire.Hosting.Tests, Aspire.Hosting.Valkey.Tests, Aspire.Hosting.Yarp.Tests, Aspire.Playground.Tests, Aspire.Templates.Tests, Infrastructure.Tests

Selected PR jobs (5)

cli-starter-validation, extension-e2e, native-dashboard-validation, polyglot, typescript-api-compat


How these were chosen — grouped by what changed

⚠️ 20 of the 56 selected test projects come from a single change — src/Aspire.Hosting/ApplicationModel/CommandsConfigurationExtensions.cs.

🔧 src/Aspire.Hosting/ApplicationModel/CommandsConfigurationExtensions.cs (changed source)
→ 20 via the project graph

show 20

Aspire.Hosting.Analyzers.Tests (2 hops), Aspire.Hosting.Azure.Provisioning.Tests (3 hops), Aspire.Hosting.Browsers.Tests (2 hops), Aspire.Hosting.CodeGeneration.Go.Tests, Aspire.Hosting.CodeGeneration.Java.Tests, Aspire.Hosting.CodeGeneration.Python.Tests, Aspire.Hosting.CodeGeneration.Rust.Tests, Aspire.Hosting.CodeGeneration.TypeScript.Tests, Aspire.Hosting.Containers.Tests (2 hops), Aspire.Hosting.DevTunnels.Tests (2 hops), Aspire.Hosting.Go.Tests (2 hops), Aspire.Hosting.Java.Tests (2 hops), Aspire.Hosting.Keycloak.Tests (2 hops), Aspire.Hosting.Maui.Tests, Aspire.Hosting.Orleans.Tests (2 hops), Aspire.Hosting.Python.Tests (2 hops), Aspire.Hosting.RemoteHost.Tests, Aspire.Hosting.Rust.Tests (2 hops), Aspire.Hosting.Yarp.Tests (2 hops), Aspire.Playground.Tests

🔧 src/Aspire.Dashboard/Components/Layout/ResourcesLayout.razor.cs (changed source)
→ 4 via the project graph: Aspire.Dashboard.Components.Tests, Aspire.Hosting.DotnetTool.Tests (2 hops), Aspire.Hosting.JavaScript.Tests, Aspire.Hosting.Testing.Tests

🔧 src/Aspire.Hosting.PostgreSQL/PostgresBuilderExtensions.cs (changed source)
→ 1 directly: Aspire.Hosting.PostgreSQL.Tests
→ 3 via the project graph: Aspire.Hosting.Docker.Tests (2 hops), Aspire.Hosting.EntityFrameworkCore.Tests (2 hops), Aspire.Hosting.Kubernetes.Tests (2 hops)

🧪 tests/Aspire.Hosting.Tests/AddConnectionStringTests.cs (changed test)
→ 1 directly: Aspire.Hosting.Tests
→ 2 via the project graph: Aspire.Hosting.Blazor.Tests, Aspire.Hosting.Dotnet.Tests

📦 affected project Aspire.Hosting.Dotnet
→ 2 tests: Aspire.Cli.EndToEnd.Tests, Aspire.Templates.Tests

🔧 src/Aspire.Hosting.Azure.ApplicationInsights/AzureApplicationInsightsResource.cs (changed source)
→ 1 directly: Aspire.Hosting.Azure.Tests
→ 1 via the project graph: Aspire.Hosting.Azure.EntraId.Tests (2 hops)

🔧 src/Aspire.Hosting.Azure.Kusto/AzureKustoClusterResource.cs (changed source)
→ 2 directly: Aspire.Hosting.Azure.Kusto.Tests, Aspire.Hosting.Azure.Tests

🔧 src/Aspire.Hosting.Azure.Kusto/AzureKustoReadWriteDatabaseResource.cs (changed source)
→ 2 directly: Aspire.Hosting.Azure.Kusto.Tests, Aspire.Hosting.Azure.Tests

🔧 src/Aspire.Hosting.MongoDB/MongoDBBuilderExtensions.cs (changed source)
→ 1 directly: Aspire.Hosting.MongoDB.Tests
→ 1 via the project graph: Aspire.Hosting.Radius.Tests

🔧 src/Shared/Model/KnownProperties.cs (changed source)
→ 2 via the project graph: Aspire.Hosting.Azure.Kubernetes.Tests, Aspire.Hosting.Azure.Tests

📦 affected project Aspire.Dashboard
→ 1 test: Aspire.Templates.Tests

📦 affected project Aspire.Hosting.Azure.Storage
→ 1 test: Aspire.Cli.EndToEnd.Tests

🔧 src/Aspire.Dashboard/Resources/Columns.resx (changed source)
→ 1 directly: Infrastructure.Tests

🔧 src/Aspire.Hosting.Azure.AppConfiguration/AzureAppConfigurationResource.cs (changed source)
→ 1 directly: Aspire.Hosting.Azure.Tests

🔧 src/Aspire.Hosting.Azure.CognitiveServices/AzureOpenAIDeploymentResource.cs (changed source)
→ 1 directly: Aspire.Hosting.Azure.Tests

🔧 src/Aspire.Hosting.Azure.CognitiveServices/AzureOpenAIResource.cs (changed source)
→ 1 directly: Aspire.Hosting.Azure.Tests

🔧 src/Aspire.Hosting.Azure.CosmosDB/AzureCosmosDBContainerResource.cs (changed source)
→ 1 directly: Aspire.Hosting.Azure.Tests

🔧 src/Aspire.Hosting.Azure.CosmosDB/AzureCosmosDBDatabaseResource.cs (changed source)
→ 1 directly: Aspire.Hosting.Azure.Tests

🔧 src/Aspire.Hosting.Azure.CosmosDB/AzureCosmosDBResource.cs (changed source)
→ 1 directly: Aspire.Hosting.Azure.Tests

🔧 src/Aspire.Hosting.Azure.EventHubs/AzureEventHubConsumerGroupResource.cs (changed source)
→ 1 directly: Aspire.Hosting.Azure.Tests

🔧 src/Aspire.Hosting.Azure.EventHubs/AzureEventHubResource.cs (changed source)
→ 1 directly: Aspire.Hosting.Azure.Tests

🔧 src/Aspire.Hosting.Azure.EventHubs/AzureEventHubsResource.cs (changed source)
→ 1 directly: Aspire.Hosting.Azure.Tests

🔧 src/Aspire.Hosting.Azure.Functions/DurableTask/DurableTaskHubResource.cs (changed source)
→ 1 directly: Aspire.Hosting.Azure.Tests

🔧 src/Aspire.Hosting.Azure.Functions/DurableTask/DurableTaskSchedulerResource.cs (changed source)
→ 1 directly: Aspire.Hosting.Azure.Tests

🔧 src/Aspire.Hosting.Azure.KeyVault/AzureKeyVaultResource.cs (changed source)
→ 1 directly: Aspire.Hosting.Azure.Tests

🔧 src/Aspire.Hosting.Azure.PostgreSQL/AzurePostgresFlexibleServerDatabaseResource.cs (changed source)
→ 1 directly: Aspire.Hosting.Azure.Tests

🔧 src/Aspire.Hosting.Azure.PostgreSQL/AzurePostgresFlexibleServerResource.cs (changed source)
→ 1 directly: Aspire.Hosting.Azure.Tests

🔧 src/Aspire.Hosting.Azure.PostgreSQL/AzurePostgresResource.cs (changed source)
→ 1 directly: Aspire.Hosting.Azure.Tests

🔧 src/Aspire.Hosting.Azure.Redis/AzureManagedRedisResource.cs (changed source)
→ 1 directly: Aspire.Hosting.Azure.Tests

🔧 src/Aspire.Hosting.Azure.Redis/AzureRedisCacheResource.cs (changed source)
→ 1 directly: Aspire.Hosting.Azure.Tests

🔧 src/Aspire.Hosting.Azure.Redis/AzureRedisResource.cs (changed source)
→ 1 directly: Aspire.Hosting.Azure.Tests

🔧 src/Aspire.Hosting.Azure.Search/AzureSearchResource.cs (changed source)
→ 1 directly: Aspire.Hosting.Azure.Tests

🔧 src/Aspire.Hosting.Azure.ServiceBus/AzureServiceBusQueueResource.cs (changed source)
→ 1 directly: Aspire.Hosting.Azure.Tests

🔧 src/Aspire.Hosting.Azure.ServiceBus/AzureServiceBusResource.cs (changed source)
→ 1 directly: Aspire.Hosting.Azure.Tests

🔧 src/Aspire.Hosting.Azure.ServiceBus/AzureServiceBusSubscriptionResource.cs (changed source)
→ 1 directly: Aspire.Hosting.Azure.Tests

🔧 src/Aspire.Hosting.Azure.ServiceBus/AzureServiceBusTopicResource.cs (changed source)
→ 1 directly: Aspire.Hosting.Azure.Tests

🔧 src/Aspire.Hosting.Azure.SignalR/AzureSignalRResource.cs (changed source)
→ 1 directly: Aspire.Hosting.Azure.Tests

🔧 src/Aspire.Hosting.Azure.Sql/AzureSqlDatabaseResource.cs (changed source)
→ 1 directly: Aspire.Hosting.Azure.Tests

🔧 src/Aspire.Hosting.Azure.Sql/AzureSqlServerResource.cs (changed source)
→ 1 directly: Aspire.Hosting.Azure.Tests

🔧 src/Aspire.Hosting.Azure.Storage/AzureBlobStorageContainerResource.cs (changed source)
→ 1 directly: Aspire.Hosting.Azure.Tests

🔧 src/Aspire.Hosting.Azure.Storage/AzureBlobStorageResource.cs (changed source)
→ 1 directly: Aspire.Hosting.Azure.Tests

🔧 src/Aspire.Hosting.Azure.Storage/AzureDataLakeStorageFileSystemResource.cs (changed source)
→ 1 directly: Aspire.Hosting.Azure.Tests

🔧 src/Aspire.Hosting.Azure.Storage/AzureDataLakeStorageResource.cs (changed source)
→ 1 directly: Aspire.Hosting.Azure.Tests

🔧 src/Aspire.Hosting.Azure.Storage/AzureQueueStorageQueueResource.cs (changed source)
→ 1 directly: Aspire.Hosting.Azure.Tests

🔧 src/Aspire.Hosting.Azure.Storage/AzureQueueStorageResource.cs (changed source)
→ 1 directly: Aspire.Hosting.Azure.Tests

🔧 src/Aspire.Hosting.Azure.Storage/AzureTableStorageResource.cs (changed source)
→ 1 directly: Aspire.Hosting.Azure.Tests

🔧 src/Aspire.Hosting.Azure.WebPubSub/AzureWebPubSubHubResource.cs (changed source)
→ 1 directly: Aspire.Hosting.Azure.Tests

🔧 src/Aspire.Hosting.Azure.WebPubSub/AzureWebPubSubResource.cs (changed source)
→ 1 directly: Aspire.Hosting.Azure.Tests

🔧 src/Aspire.Hosting.Foundry/FoundryDeploymentResource.cs (changed source)
→ 1 directly: Aspire.Hosting.Foundry.Tests

🔧 src/Aspire.Hosting.Foundry/FoundryResource.cs (changed source)
→ 1 directly: Aspire.Hosting.Foundry.Tests

🔧 src/Aspire.Hosting.Foundry/Project/ProjectResource.cs (changed source)
→ 1 directly: Aspire.Hosting.Foundry.Tests

🔧 src/Aspire.Hosting.Foundry/PromptAgent/AzurePromptAgentResource.cs (changed source)
→ 1 directly: Aspire.Hosting.Foundry.Tests

🔧 src/Aspire.Hosting.Foundry/Toolbox/FoundryToolboxResource.cs (changed source)
→ 1 directly: Aspire.Hosting.Foundry.Tests

🔧 src/Aspire.Hosting.Garnet/GarnetResource.cs (changed source)
→ 1 directly: Aspire.Hosting.Garnet.Tests

🔧 src/Aspire.Hosting.Kafka/KafkaServerResource.cs (changed source)
→ 1 directly: Aspire.Hosting.Kafka.Tests

🔧 src/Aspire.Hosting.Milvus/MilvusDatabaseResource.cs (changed source)
→ 1 directly: Aspire.Hosting.Milvus.Tests

🔧 src/Aspire.Hosting.Milvus/MilvusServerResource.cs (changed source)
→ 1 directly: Aspire.Hosting.Milvus.Tests

🔧 src/Aspire.Hosting.MongoDB/MongoDBDatabaseResource.cs (changed source)
→ 1 directly: Aspire.Hosting.MongoDB.Tests

🔧 src/Aspire.Hosting.MongoDB/MongoDBServerResource.cs (changed source)
→ 1 directly: Aspire.Hosting.MongoDB.Tests

🔧 src/Aspire.Hosting.MongoDB/ReplicaSet/MongoDBReplicaSetResource.cs (changed source)
→ 1 directly: Aspire.Hosting.MongoDB.Tests

🔧 src/Aspire.Hosting.MySql/MySqlBuilderExtensions.cs (changed source)
→ 1 directly: Aspire.Hosting.MySql.Tests

🔧 src/Aspire.Hosting.MySql/MySqlDatabaseResource.cs (changed source)
→ 1 directly: Aspire.Hosting.MySql.Tests

🔧 src/Aspire.Hosting.MySql/MySqlServerResource.cs (changed source)
→ 1 directly: Aspire.Hosting.MySql.Tests

🔧 src/Aspire.Hosting.Nats/NatsServerResource.cs (changed source)
→ 1 directly: Aspire.Hosting.Nats.Tests

🔧 src/Aspire.Hosting.OpenAI/OpenAIExtensions.cs (changed source)
→ 1 directly: Aspire.Hosting.OpenAI.Tests

🔧 src/Aspire.Hosting.OpenAI/OpenAIModelResource.cs (changed source)
→ 1 directly: Aspire.Hosting.OpenAI.Tests

🔧 src/Aspire.Hosting.OpenAI/OpenAIResource.cs (changed source)
→ 1 directly: Aspire.Hosting.OpenAI.Tests

🔧 src/Aspire.Hosting.Oracle/OracleDatabaseResource.cs (changed source)
→ 1 directly: Aspire.Hosting.Oracle.Tests

🔧 src/Aspire.Hosting.Oracle/OracleDatabaseServerResource.cs (changed source)
→ 1 directly: Aspire.Hosting.Oracle.Tests

🔧 src/Aspire.Hosting.PostgreSQL/PostgresDatabaseResource.cs (changed source)
→ 1 directly: Aspire.Hosting.PostgreSQL.Tests

🔧 src/Aspire.Hosting.PostgreSQL/PostgresServerResource.cs (changed source)
→ 1 directly: Aspire.Hosting.PostgreSQL.Tests

🔧 src/Aspire.Hosting.Qdrant/QdrantServerResource.cs (changed source)
→ 1 directly: Aspire.Hosting.Qdrant.Tests

🔧 src/Aspire.Hosting.RabbitMQ/RabbitMQServerResource.cs (changed source)
→ 1 directly: Aspire.Hosting.RabbitMQ.Tests

🔧 src/Aspire.Hosting.Redis/RedisBuilderExtensions.cs (changed source)
→ 1 directly: Aspire.Hosting.Redis.Tests

🔧 src/Aspire.Hosting.Redis/RedisResource.cs (changed source)
→ 1 directly: Aspire.Hosting.Redis.Tests

🔧 src/Aspire.Hosting.Seq/SeqResource.cs (changed source)
→ 1 directly: Aspire.Hosting.Seq.Tests

🔧 src/Aspire.Hosting.SqlServer/SqlServerBuilderExtensions.cs (changed source)
→ 1 directly: Aspire.Hosting.SqlServer.Tests

🔧 src/Aspire.Hosting.SqlServer/SqlServerDatabaseResource.cs (changed source)
→ 1 directly: Aspire.Hosting.SqlServer.Tests

🔧 src/Aspire.Hosting.SqlServer/SqlServerServerResource.cs (changed source)
→ 1 directly: Aspire.Hosting.SqlServer.Tests

🔧 src/Aspire.Hosting.Valkey/ValkeyResource.cs (changed source)
→ 1 directly: Aspire.Hosting.Valkey.Tests

🔧 src/Aspire.Hosting/ApplicationModel/KnownResourceStates.cs (changed source)
→ 1 via the project graph: Aspire.Cli.Tests

🧪 tests/Aspire.Dashboard.Tests/Model/ResourceStateViewModelTests.cs (changed test)
→ 1 directly: Aspire.Dashboard.Tests

🧪 tests/Aspire.Hosting.Tests/AddParameterTests.cs (changed test)
→ 1 directly: Aspire.Hosting.Tests

🧪 tests/Aspire.Hosting.Tests/Dcp/DcpExecutorTests.cs (changed test)
→ 1 directly: Aspire.Hosting.Tests

🧪 tests/Aspire.Hosting.Tests/Orchestrator/ApplicationOrchestratorTests.cs (changed test)
→ 1 directly: Aspire.Hosting.Tests

🧪 tests/Aspire.Hosting.Tests/ResourceCommandAnnotationTests.cs (changed test)
→ 1 directly: Aspire.Hosting.Tests

🧪 tests/Aspire.Hosting.Tests/WithUrlsTests.cs (changed test)
→ 1 directly: Aspire.Hosting.Tests

Job reasons

Job Triggered by
cli-starter-validation affected project Aspire.Hosting.PostgreSQL
extension-e2e • src/Aspire.Dashboard/Components/Layout/ResourcesLayout.razor.cs, src/Aspire.Dashboard/Extensions/ResourceViewModelExtensions.cs, src/Aspire.Dashboard/Model/KnownResourceState.cs, src/Aspire.Dashboard/Model/ResourceStateViewModel.cs, src/Aspire.Dashboard/Model/ResourceViewModelExtensions.cs, src/Aspire.Dashboard/Resources/Columns.Designer.cs, src/Aspire.Dashboard/Resources/Columns.resx, src/Aspire.Dashboard/Resources/xlf/Columns.cs.xlf, src/Aspire.Dashboard/Resources/xlf/Columns.de.xlf, src/Aspire.Dashboard/Resources/xlf/Columns.es.xlf, src/Aspire.Dashboard/Resources/xlf/Columns.fr.xlf, src/Aspire.Dashboard/Resources/xlf/Columns.it.xlf, src/Aspire.Dashboard/Resources/xlf/Columns.ja.xlf, src/Aspire.Dashboard/Resources/xlf/Columns.ko.xlf, src/Aspire.Dashboard/Resources/xlf/Columns.pl.xlf, src/Aspire.Dashboard/Resources/xlf/Columns.pt-BR.xlf, src/Aspire.Dashboard/Resources/xlf/Columns.ru.xlf, src/Aspire.Dashboard/Resources/xlf/Columns.tr.xlf, src/Aspire.Dashboard/Resources/xlf/Columns.zh-Hans.xlf, src/Aspire.Dashboard/Resources/xlf/Columns.zh-Hant.xlf, src/Aspire.Hosting.Azure.Functions/DurableTask/DurableTaskHubResource.cs, src/Aspire.Hosting.Azure.Functions/DurableTask/DurableTaskSchedulerResource.cs, src/Aspire.Hosting.Redis/RedisBuilderExtensions.cs, src/Aspire.Hosting.Redis/RedisResource.cs, src/Aspire.Hosting/ApplicationModel/CommandsConfigurationExtensions.cs, src/Aspire.Hosting/ApplicationModel/HttpsCertificateExecutionConfigurationGatherer.cs, src/Aspire.Hosting/ApplicationModel/IResourceWithConnectionString.cs, src/Aspire.Hosting/ApplicationModel/IValueProvider.cs, src/Aspire.Hosting/ApplicationModel/KnownResourceStates.cs, src/Aspire.Hosting/ApplicationModel/ParameterResource.cs, src/Aspire.Hosting/ApplicationModel/ResourceNotificationService.cs, src/Aspire.Hosting/ApplicationModel/ResourceUrlsCallbackContext.cs, src/Aspire.Hosting/ApplicationModel/ResourceUrlsEditor.cs, src/Aspire.Hosting/ConnectionStringParameterResource.cs, src/Aspire.Hosting/ConnectionStringResource.cs, src/Aspire.Hosting/Dcp/ContainerCreator.cs, src/Aspire.Hosting/ExternalServiceBuilderExtensions.cs, src/Aspire.Hosting/Orchestrator/ApplicationOrchestrator.cs, src/Aspire.Hosting/ResourceBuilderExtensions.cs
• affected project Aspire.Dashboard
native-dashboard-validation affected project Aspire.Dashboard
polyglot • affected project Aspire.Hosting.Azure.AppConfiguration
• affected project Aspire.Hosting.Azure.Provisioning.AppConfiguration
typescript-api-compat affected project Aspire.Hosting.Azure.AppConfiguration

Selection computed for commit 128d945.

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.

🔵 Needs a closer look

Human assessment is needed because subtle context-propagation and explicit-start lifecycle regressions can break redirected database connectivity and hide parameter waits.

No open issues 🎉

1 resolved since last review
1 file not reviewed
  • src/Aspire.Dashboard/Resources/Columns.Designer.cs: Generated file

Review effort: Balanced

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

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

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

@sebastienros

Copy link
Copy Markdown
Contributor

Is the intent to ship it in 17? From what I understand this is not something that is broken today, but an improvement to let users know what the resource is blocked on, right?

@sebastienros

Copy link
Copy Markdown
Contributor

Was it intentional to only apply the new pattern to PostgreSQL, Redis and SQL Server?

@JamesNK
James Newton-King (JamesNK) marked this pull request as draft November 15, 2026 22:57
@JamesNK

James Newton-King (JamesNK) commented Nov 15, 2026 •

Copy link
Copy Markdown
Member Author

Is the intent to ship it in 17? From what I understand this is not something that is broken today, but an improvement to let users know what the resource is blocked on, right?

No, it's a weekend experiment.

Was it intentional to only apply the new pattern to PostgreSQL, Redis and SQL Server?

It's applied everywhere. Only resources that access parameters directly need to be updated to pass in the context. It happens automatically if parameters are used in an expression.

@sebastienros

Copy link
Copy Markdown
Contributor

There are other things missing then, I'll send the agent's review

image image

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.

I tried this locally at 128d9450d5. The mechanism works for PostgreSQL, Redis and SQL Server, but not for the other connection-string integrations.

Missing passwords still aren't reported for MySQL, Valkey, MongoDB and others

AddMySql registers its own ConnectionStringAvailableEvent handler, and that handler still reads the connection string without context:

builder.Eventing.Subscribe<ConnectionStringAvailableEvent>(resource, async (@event, ct) =>
{
connectionString = await resource.ConnectionStringExpression.GetValueAsync(ct).ConfigureAwait(false);

Here is why that blocks:

  1. DcpExecutor awaits PublishConnectionStringAvailableEventAsync before it publishes OnResourceStartingContext and before CreateObjectAsync.
  2. DistributedApplicationEventing runs handlers one at a time, in the order they were subscribed (BlockingSequential).
  3. AddMySql subscribes when the AppHost is built. ApplicationOrchestrator subscribes PublishConnectionStringValue later.

So the MySQL handler blocks on the password with no Caller. The orchestrator's handler, which does pass a Caller, never runs. The "Starting" update and container creation never happen either, and with them goes the environment-variable resolution that would have reported the parameter.

Test. I added cases to this PR's ConnectionStringAvailableEventReportsMissingPasswordBeforeStarting. postgres, redis and publisher pass. mysql, valkey and mongodb all fail with:

Assert.Equal() Failure: Strings differ
Expected: "UnresolvedParameters"
Actual:   null

Real AppHost. I ran AddMySql("mysql", password: p1) and AddPostgres("postgres", password: p2), with neither parameter set:

  • postgres shows Unresolved parameters, "Waiting for parameters: postgres-password", and resource.unresolvedParameters.
  • mysql shows Unknown, with no state details and no property.

The same context-free pattern is in:

  • ValkeyBuilderExtensions.cs:134
  • GarnetBuilderExtensions.cs:118
  • OracleDatabaseBuilderExtensions.cs:47
  • KafkaBuilderExtensions.cs:46
  • NatsBuilderExtensions.cs:66 and :79-80
  • MongoDBBuilderExtensions.cs:102 and :276
  • AzureCosmosDBExtensions.cs:122
  • AzureStorageExtensions.cs:221 and :224

The MongoDB replica-set initializer has it too, at MongoDBReplicaSetBuilderExtensions.cs:131 and :151. A replica set whose sharedPassword parameter has no value blocks initialization with no attribution.

These handlers can be fixed one at a time, but third-party integrations would still miss out. See the inline comment on ApplicationOrchestrator for a more central option.

Smaller things outside the diff

  • McpToolHelpers.MapResourceState (src/Aspire.Cli/Mcp/Tools/McpToolHelpers.cs:167) uses a fixed list of states. It reports UnresolvedParameters as "unknown", so agents using list_resources or wait_for_resources can't tell that a parameter needs a value.
  • The VS Code extension's EditorAssistanceResourceState union (extension/src/lm/editorAssistanceToolContracts.ts) has the same gap.

The inline comments are from reading the code. I haven't reproduced them.

Caller = resourceWithConnectionString,
Network = KnownNetworkIdentifiers.LocalhostNetwork
};
var connectionString = await resourceWithConnectionString.GetConnectionStringAsync(valueContext, token).ConfigureAwait(false);

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.

This handler passes a Caller, but it's subscribed after every integration's resource-scoped ConnectionStringAvailableEvent handler. Any integration handler that reads the connection string without context blocks first, so this code never runs (see the review summary).

Rather than fixing each integration, could this be handled centrally? Two options:

  • Register the parameter waits for the resource's referenced parameters before the event is dispatched.
  • Put a ready-made ValueProviderContext on ConnectionStringAvailableEvent that handlers can pass along.

Either one would also cover third-party integrations, which otherwise have to know to build new ValueProviderContext { ExecutionContext, Caller, Network = Localhost } by hand.

/// =&gt; ConnectionStringExpression.GetValueAsync(context, cancellationToken);
/// </code>
/// </remarks>
public ValueTask<string?> GetConnectionStringAsync(ValueProviderContext context, CancellationToken cancellationToken) =>

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.

Two things on this new overload:

  1. No default for cancellationToken. The sibling overloads IValueProvider.GetValueAsync(ValueProviderContext, CancellationToken = default) and GetConnectionStringAsync(CancellationToken = default) both have one. The implementations on Postgres, Redis, SqlServer and KeyVault also make it required. As a result, resource.GetConnectionStringAsync(ctx) doesn't compile while GetValueAsync(ctx) does. Since this is new public API, this is the moment to make them match.
  2. The default drops the context. I see that's deliberate, to keep custom resolvers working. The side effect is that a resource overriding neither overload gives different answers depending on the path. GetConnectionStringAsync(ctx) returns the localhost form and records no parameter wait. ((IValueProvider)r).GetValueAsync(ctx) honours Network and Caller.


ValueTask<string?> IValueProvider.GetValueAsync(ValueProviderContext context, CancellationToken cancellationToken) =>
ConnectionStringExpression.GetValueAsync(context, cancellationToken);
HasContextualConnectionStringImplementation(this.GetType())

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.

The probe could also check whether GetConnectionStringAsync(CancellationToken) itself is overridden. When it isn't, nothing custom needs preserving, so the default could use ConnectionStringExpression.GetValueAsync(context, ct) directly.

That would remove about 60 copies of the same => ConnectionStringExpression.GetValueAsync(context, cancellationToken) override in this PR. Only real custom resolvers (Postgres, Redis, SqlServer, KeyVault) would need to override it. Third-party resources would get the attribution automatically instead of losing it whenever someone forgets the override.

static bool IsStopped(string? state) => KnownResourceStates.TerminalStates.Contains(state) || state == KnownResourceStates.NotStarted || state == "Unknown";
static bool IsStopping(string? state) => state == KnownResourceStates.Stopping;
static bool IsStarting(string? state) => state == KnownResourceStates.Starting;
static bool IsStarting(string? state) => state == KnownResourceStates.Starting || state == KnownResourceStates.UnresolvedParameters;

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.

IsStarting handles the new state, but the rebuild paths in this file still compare raw state text:

  • Stop step: replicasToStop (around L225) treats a replica in UnresolvedParameters as not waiting, so it gets stopped. The comment there says stopping a replica that has no DCP object yet fails.
  • Restart step: ShouldRestartAfterRebuild (around L387) only matches Running, Starting or empty. A replica captured as UnresolvedParameters is therefore restored to that stale text instead of being restarted on the new binary.

// dependencies are ready, so use the pending list to identify active dependency waits.
// Leaving Waiting during an active dependency wait would release WaitFor prematurely.
// URL callbacks can resolve parameters before a resource has a state.
if (snapshot.State is null || snapshot.State.Text == KnownResourceStates.Starting ||

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.

While a wait is active, the real Starting or Waiting state is replaced by UnresolvedParameters in the stored snapshot. Every later stateFactory therefore receives the substitute state. Existing factories that branch on the previous state then take a different branch:

  • ApplicationOrchestrator.StartResourceAsync (around L729) checks s.State?.Text == Waiting so it can force Starting and skip the DCP start call, because that call conflicts. With the state replaced, it falls through and asks DCP to start the resource.
  • The Start command's IsWaiting → Enabled check no longer matches, so a resource that could be force-started before now can't be.

Could the real state be kept in the snapshot, with the substitution applied only when the state is shown? Alternatively, factories could get the saved state.

{
foreach (var resourceId in resourceIds)
{
await PublishUpdateAsync(resource, resourceId, snapshot =>

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.

A parameter read now calls PublishUpdateAsync around itself, which adds two ways for the read to fail:

  • Instance mismatch. PublishUpdateAsync throws "Resource instance doesn't match resource previously registered..." when Caller isn't the instance registered for that ID, for example after a resource has been swapped for another of the same name. A read that used to just wait now fails startup.
  • Failure in finally. If the publish that removes the wait (L1054) throws after await valueTask has succeeded, the resolved value is lost and the exception is thrown instead.

Should failures in both directions be caught and logged here? The wait reporting only feeds the dashboard, so it probably shouldn't be able to fail the read itself.

{
// Capture instance IDs once so cancellation removes waits from the instances that registered
// them, even if the resource's replica set changes in the meantime.
var resourceIds = resource.GetResolvedResourceNames();

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.

Caller is the model resource, so GetResolvedResourceNames() returns every replica. A read made while configuring one replica, such as one being restarted, records a wait on all its siblings. Replicas that are fully resolved and only waiting on DCP then show UnresolvedParameters, and each replica's own reads add to every other replica's count.

Is there a way to get the specific replica name through the context, for example DcpResourceName?

var count = waits[parameter.Name];
if (count == 1)
{
waits.Remove(parameter.Name);

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.

Once the last wait is removed, ParameterWaits stays as an empty dictionary rather than going back to null. As a result, the ParameterWaits is null early return in UpdateParameterWaitState no longer applies.

After one startup wait, every later update for that resource (DCP watch replays, health reports) takes the else if branch and allocates a new Properties array just to remove a property that isn't there. Setting ParameterWaits = null when the count reaches zero would avoid that.

builder.Eventing.Subscribe<ConnectionStringAvailableEvent>(postgresServer, async (@event, ct) =>
{
connectionString = await postgresServer.GetConnectionStringAsync(ct).ConfigureAwait(false);
connectionString = await postgresServer.GetConnectionStringAsync(new ValueProviderContext

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.

Nit: this new ValueProviderContext { ExecutionContext = …, Caller = …, Network = KnownNetworkIdentifiers.LocalhostNetwork } block now appears in about 7 places:

  • ApplicationOrchestrator
  • Postgres, Redis and SqlServer
  • ContainerCreator
  • WithUrl and ResourceUrlsEditor

Other new call sites set Caller but not Network:

  • phpMyAdmin, pgAdmin and pgweb config
  • the Redis password read
  • OpenAI OnInitializeResource

That's harmless today, because those values are parameters or the caller isn't a container. Still, setting Caller alone switches GetNetworkIdentifier to the caller's default network, which will bite the first time someone copies the pattern for a container's endpoint. A small internal helper such as ValueProviderContext.ForHost(executionContext, caller) would make "localhost, but attribute the wait" explicit and avoid that.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants