-
Notifications
You must be signed in to change notification settings - Fork 703
Made changes to how parameter.Value works #10354
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Value now blocks (sync over async) waiting for value resolution if WaitForValueTcs is set. - Made GetValueAsync on ParameterResource public. - Changed most code outside of tests to use GetValueAsync instead of Value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR ensures that parameter values are resolved consistently by making ParameterResource.Value
block on async resolution, exposing GetValueAsync
, and updating callers to use the async API.
- ParameterResource.Value now synchronously awaits the async resolution path
GetValueAsync
is made public and most callers switch from.Value
to.GetValueAsync(...)
- Call sites in various builder extensions are updated to await parameter values
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.
Show a summary per file
File | Description |
---|---|
src/Aspire.Hosting/ResourceBuilderExtensions.cs | Await URL parameter resolution in WithEnvironment |
src/Aspire.Hosting/Orchestrator/ParameterProcessor.cs | Switched from Value to ValueInternal in parameter processing |
src/Aspire.Hosting/ExternalServiceBuilderExtensions.cs | Expose async URL retrieval and adjust initial state |
src/Aspire.Hosting/ApplicationModel/ParameterResource.cs | Made GetValueAsync public and unified Value implementation |
src/Aspire.Hosting.Redis/RedisBuilderExtensions.cs | Use async resolution for Redis password parameter |
src/Aspire.Hosting.MySql/MySqlBuilderExtensions.cs | Await MySQL password parameter in PhpMyAdmin setup |
src/Aspire.Hosting.Azure/Provisioning/Provisioners/BicepProvisioner.cs | Use GetValueAsync for parameter-based resource group names |
Comments suppressed due to low confidence (1)
src/Aspire.Hosting/ApplicationModel/ParameterResource.cs:89
- New public API
GetValueAsync
was introduced but there are no unit tests for it. Consider adding tests to cover waiting onWaitForValueTcs
and the fallback toValueInternal
.
public async ValueTask<string?> GetValueAsync(CancellationToken cancellationToken)
/backport to release/9.4 |
Started backporting to release/9.4: https://github.com/dotnet/aspire/actions/runs/16240431419 |
Description
This was found while dogfooding the latest build with async parameter resolution. We were using ParameterResource.Value is many places and as a result those places did not properly wait for values to be resolved before continuing, they just failed. Now ParameterResource.Value calls
ParameterResource.GetValueAsync(...).GetAwaiter().GetResult()
, which is not great, but is consistent. We need the sync and async versions to work exactly the same way to avoid inconsistent state.There's a risk with introducing deadlocks with this change for people that were using .Value before.
I'm working through tests now to make sure that does not happen in practice.👍🏾 If the Value is accessed before the TCS is set then it will throw an exception like it did before.Fixes #10352
Checklist