microsoft / microsoft/aspire

pipelines: Using interaction service ConfirmationPrompt hangs the step

Open
#13,923 1 comment 0 reactions 0 assignees View on GitHub
needs-area-label
Dominant language
C#
Stars
6.3k
Forks
991
Avg merge
2d 15h
Merged PRs (30d)
196

Description

### Is there an existing issue for this?

- [x] I have searched the existing issues

### Describe the bug

The docs state that:

> The `PromptConfirmationAsync` method isn’t available in CLI contexts. If you call it during aspire publish or aspire deploy, the method throws an exception.

This may be the case, but when calling `aspire do`, it does _not_ throw an exception and instead just hangs while waiting for... nothing.

### Expected Behavior

I don't understand _why_ it's not available when we can use `PromptForInputs` and then use `InputType.Boolean` -- I expected to be able to use a prompt confirmation before a destructive action using that API.

However, at the very least, I would expect it to throw as unsupported.

### Steps To Reproduce

```c#
pipelines.AddStep('confirm', async (context) => {
var interaction = context.Services.GetRequiredService();

var shouldDelete = await interaction.PromptConfirmationAsync(
"Confirm Deletion", $"Deleting resource group {resourceGroupName}",
cancellationToken: context.CancellationToken);

// never reaches here
if (shouldDelete.Data is true) {

}
});
```

### Exceptions (if any)

_No response_

### .NET Version info

.NET 10

### Anything else?

Aspire 13.1

This code is what I'm using that works (which is what I was originally trying to do with prompt confirmation):

```c#
if (interaction.IsAvailable)
{
var shouldDelete = await interaction.PromptInputsAsync(
"Confirm Deletion", $"Deleting resource group {resourceGroupName}",
cancellationToken: context.CancellationToken,
inputs: [
new() {
Name = "Confirm?",
Required = true,
InputType = InputType.Boolean
}
]).ConfigureAwait(false);

if (shouldDelete.Canceled || bool.Parse(shouldDelete.Data[0].Value ?? "false") is false) {
continue;
}
}

await DeleteResourceGroup(resourceGroupName, context.CancellationToken).ConfigureAwait(false);
```

Contributor guide

Open the contributing guide

Research direction

Start at the IInteractionService PromptConfirmationAsync entry point and trace its behavior when called from an aspire do pipeline step. Compare it with PromptInputsAsync and the documented publish/deploy behavior; done means aspire do no longer hangs and the unsupported use either behaves consistently or throws an exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.