You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Show resources waiting for parameters during startup - #22291
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:
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:
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:
Validation
739 targeted tests passed on the current changes. Quarantined and outerloop tests were excluded.
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?
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.
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.
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.
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.
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.
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.
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.
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.
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
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.
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.
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?
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.
DcpExecutor awaits PublishConnectionStringAvailableEventAsync before it publishes OnResourceStartingContext and before CreateObjectAsync.
DistributedApplicationEventing runs handlers one at a time, in the order they were subscribed (BlockingSequential).
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:
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.
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.
The reason will be displayed to describe this comment to others. Learn more.
Two things on this new overload:
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.
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.
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.
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.
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.
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.
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?
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.
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 toValueProviderContext.Caller; it does not predict dependencies by walking the resource model.Behavior and implementation
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.User-facing usage
No extra configuration is required for ordinary parameter references:
While
postgres-passwordis missing,postgresreportsKnownResourceStates.UnresolvedParametersand 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
ValueProviderContextcontaining the execution context and requesting resource toGetValueAsync.Custom connection-string resources can implement the new contextual overload:
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:
Validation
739 targeted tests passed on the current changes. Quarantined and outerloop tests were excluded.
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'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'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'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'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'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'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'git diff --cached --checkAll 33 affected Hosting projects were also compiled together using a temporary validation solution, which was removed afterward. The build succeeded with an existing
MySqlConnectorvulnerability warning; dashboard validation also reported an existingMicrosoft.Extensions.Validationadvisory.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-keyreduced the callback's list fromapi-key, regiontoregion; supplyingregionlet both executables finish successfully with exit code 0. The demo was stopped and removed.The full test suite was not run.
Fixes # (issue)
Checklist
<remarks />and<code />elements on your triple slash comments?