microsoft/aspire · error · NonInteractiveException
The value ' ' is not valid for .
Error message
The value '{0}' is not valid for {1}. What it means
When the CLI runs non-interactively (no TTY), ConsoleInteractionService validates each prompt-bound value with the symbol's validator. If the validator rejects the value, it displays this formatted message naming the value and the option's display name, then throws NonInteractiveException to abort the command instead of looping on a prompt that cannot be shown.
Solutions
- Fix the --option value passed on the command line so it passes the symbol's validator
- Run the command interactively once to see which values are accepted, then reuse them in the script
- Inspect the validator for the symbol to learn the accepted format
Example fix
// before aspire add redis --name "my cache!" // after aspire add redis --name myCache
Defensive patterns
Strategy: validation
Validate before calling
if (string.IsNullOrWhiteSpace(value) || !allowedRegex.IsMatch(value))
throw new ArgumentException($"'{value}' is not a valid value for the option."); Try / catch
try { await cli.InvokeAsync(args); }
catch (NonInteractiveException ex) { logger.LogError(ex, "Non-interactive value rejected: {Msg}", ex.Message); } Prevention
- Validate option values in scripts before passing them to the CLI
- Avoid running value-heavy prompts in CI; prefer flags with pre-checked values
- After CLI upgrades, re-verify choice/validator constraints still accept your values
When it happens
Trigger: Calling an Aspire CLI command non-interactively (e.g. piped stdin or CI) with an --option value that fails the symbol's validator function passed to the prompt/interaction API.
Common situations: CI scripts or shell pipelines passing typoed or malformed option values; validators added to prompts that existing scripts' values no longer satisfy; values containing characters the validator rejects.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- Aspire skills bundle contains an empty relative path.
- Aspire skills bundle skill
- Aspire skills bundle version
- Cannot perform destructive operation without confirmation…
- Live rendering requires interactive output.
AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16).
Data as JSON: /api/errors/ae669c85069e1294.
Report an issue: GitHub.
Appendix: source
Thrown at src/Aspire.Cli/Interaction/ConsoleInteractionService.cs:829
{
DisplayError(string.Format(CultureInfo.CurrentCulture, InteractionServiceStrings.NonInteractiveOptionRequired, symbolDisplayName));
throw new NonInteractiveException(symbolDisplayName);
}
internal void ValidateResolvedStringValue(string value, bool required, Func<string, ValidationResult>? validator, string symbolDisplayName)
{
if (required && string.IsNullOrEmpty(value))
{
ThrowNonInteractiveError(symbolDisplayName);
}
if (validator is not null)
{
var result = validator(value);
if (!result.Successful)
{
DisplayError(result.Message ?? string.Format(CultureInfo.CurrentCulture, InteractionServiceStrings.NonInteractiveInvalidValue, value, symbolDisplayName));
throw new NonInteractiveException(symbolDisplayName);
}
}
}
[DoesNotReturn]
internal void ThrowNonInteractiveInvalidValue<T>(string value, string symbolDisplayName, IEnumerable<T> choices, Func<T, string> choiceFormatter) where T : notnull
{
DisplayError(string.Format(CultureInfo.CurrentCulture, InteractionServiceStrings.NonInteractiveInvalidValue, value, symbolDisplayName));
// Strip Spectre markup from each formatted choice so non-interactive callers see plain
// text. Some choice formatters intentionally include [bold]/[dim]/etc. tokens for the
// interactive multi-select renderer; those tokens would otherwise leak verbatim through
// DisplaySubtleMessage and confuse anyone diagnosing a typoed --option value.
var availableChoices = string.Join(", ", choices.Select(c => StringUtils.RemoveMarkup(choiceFormatter(c))));
DisplaySubtleMessage(string.Format(CultureInfo.CurrentCulture, InteractionServiceStrings.NonInteractiveAvailableValues, availableChoices));
throw new NonInteractiveException(symbolDisplayName);
}
internal T MatchChoiceOrThrow<T>(string value, PromptBinding<string?> binding, IEnumerable<T> choices, Func<T, string> choiceFormatter) where T : notnullView on GitHub (pinned to 25830f84bd)