Skip to content

Conversation

@davidfowl
Copy link
Member

@davidfowl davidfowl commented Jul 3, 2025

Description

  • Handle prompting for parameters once they have all been processed. This also handles re-prompting until they have all been processed.
  • Introduced MissingParameterValueException to detect when parameters are have a missing value.
  • Moved all parameter processing logic into ParameterProcessor
Screen.Recording.2025-07-03.010951.mp4

Missing features

  • Optional persistence of parameters to user secrets
  • Changing the state of dependent waiting resources to "waiting on parameter" or something like that.

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
  • Does the change require an update in our Aspire docs?

- Handle prompting for parameters once they have all been processed. This also handles re-prompting until they have all been processed.
- Introduced MissingParameterValueException to detect when parameters are have a missing value.
- Moved all parameter processing logic into ParameterProcessor
@github-actions github-actions bot added the area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication label Jul 3, 2025
@davidfowl davidfowl requested a review from JamesNK July 3, 2025 07:10
@davidfowl davidfowl marked this pull request as ready for review July 3, 2025 07:14
Copilot AI review requested due to automatic review settings July 3, 2025 07:14
@davidfowl davidfowl requested a review from mitchdenny as a code owner July 3, 2025 07:14
@davidfowl davidfowl changed the title Added support for prompting for parameter values Added support for prompting for parameter values in run mode Jul 3, 2025
Copy link
Contributor

Copilot AI left a 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 centralizes parameter handling into a new ParameterProcessor, introduces MissingParameterValueException for missing parameter values, and updates existing builders and orchestrator to use this new flow.

  • Tests now expect MissingParameterValueException instead of DistributedApplicationException.
  • A ParameterProcessor class encapsulates init/handling logic for ParameterResource.
  • The orchestrator and builder are updated to register and invoke the new processor upfront.

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/Aspire.Hosting.Tests/WithReferenceTests.cs Updated exception assertion to MissingParameterValueException.
tests/Aspire.Hosting.Tests/WithEnvironmentTests.cs Updated exception assertion to MissingParameterValueException.
tests/Aspire.Hosting.Tests/Orchestrator/ParameterProcessorTests.cs Added comprehensive tests for parameter initialization and unresolved handling.
tests/Aspire.Hosting.Tests/Orchestrator/ApplicationOrchestratorTests.cs Registered and passed ParameterProcessor in orchestrator factory helper.
src/Aspire.Hosting/ParameterResourceBuilderExtensions.cs Threw MissingParameterValueException instead of generic.
src/Aspire.Hosting/Orchestrator/ParameterProcessor.cs New class with async init and interactive re-prompt loop.
src/Aspire.Hosting/Orchestrator/ApplicationOrchestrator.cs Injected and invoked ParameterProcessor during startup.
src/Aspire.Hosting/DistributedApplicationBuilder.cs Registered ParameterProcessor in DI container.
src/Aspire.Hosting/ApplicationModel/ParameterResource.cs Extended to await a TaskCompletionSource for late-bound values.
src/Aspire.Hosting/ApplicationModel/MissingParameterValueException.cs New exception type with XML docs.
Comments suppressed due to low confidence (1)

src/Aspire.Hosting/Orchestrator/ApplicationOrchestrator.cs:440

  • [nitpick] It would be beneficial to add a unit test in ApplicationOrchestratorTests to verify that ParameterProcessor.InitializeParametersAsync is invoked and correctly initializes parameters during orchestration startup.
        await _parameterProcessor.InitializeParametersAsync(_model.Resources.OfType<ParameterResource>()).ConfigureAwait(false);

@@ -0,0 +1,375 @@
// Licensed to the .NET Foundation under one or more agreements.
Copy link

Copilot AI Jul 3, 2025

Choose a reason for hiding this comment

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

[nitpick] This test class is over 350 lines long, covering multiple scenarios. Consider splitting it into smaller, focused test classes (e.g., initialization tests vs. unresolved-parameter handling tests) to improve readability and maintainability.

Copilot uses AI. Check for mistakes.
{
private readonly List<ParameterResource> _unresolvedParameters = [];

public async Task InitializeParametersAsync(IEnumerable<ParameterResource> parameterResources)
Copy link
Member

Choose a reason for hiding this comment

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

Should this take a cancellation token?

Copy link
Member

@mitchdenny mitchdenny left a comment

Choose a reason for hiding this comment

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

🚢

@davidfowl davidfowl merged commit c52b57a into main Jul 3, 2025
252 checks passed
@davidfowl davidfowl deleted the davidfowl/parameter-prompting branch July 3, 2025 15:35
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants