microsoft/aspire · error · InvalidOperationException
Unexpected input type
Error message
Unexpected input type: {inputType} What it means
MapInputType converts the host-side InputType enum to the dashboard's protobuf InputType enum for interactive resource inputs. Hitting the default arm means an InputType value exists in the hosting enum that this mapper doesn't know — usually a version mismatch between the AppHost package and the dashboard proto contract, or a newly added enum member.
Solutions
- Align Aspire.Hosting and dashboard-related package versions across the solution (update all to the same Aspire version)
- If you cast ints to InputType, validate with Enum.IsDefined before use
- If you hit this on a stock setup, report it — it's an internal invariant violation between host and dashboard
Example fix
// before var type = (InputType)42; interaction.InputType = type; // after if (!Enum.IsDefined(typeof(InputType), value)) throw new ArgumentOutOfRangeException(nameof(value)); interaction.InputType = (InputType)value;
Defensive patterns
Strategy: type-guard
Validate before calling
if (!Enum.IsDefined(typeof(InputType), inputType))
throw new InvalidEnumArgumentException(nameof(inputType), (int)inputType, typeof(InputType)); Type guard
static bool IsKnownInputType(InputType t) => t is InputType.Text or InputType.SecretText or InputType.Choice or InputType.Boolean or InputType.Number or InputType.File;
Try / catch
try { /* create interaction / map input type */ }
catch (InvalidOperationException ex) when (ex.Message.Contains("Unexpected input type")) { /* check package version alignment */ } Prevention
- Keep all Aspire.* packages on the same version in the solution
- Never cast raw ints to InputType without Enum.IsDefined
- After upgrading Aspire, rebuild everything so host and dashboard contracts match
When it happens
Trigger: An interaction is created with an InputType value (e.g. added in a newer Aspire version) that the deployed/older dashboard proto mapping lacks; passing a raw or cast numeric value into the enum that isn't a defined member.
Common situations: Mixed-version Aspire packages in one solution (hosting package newer than dashboard transport contracts); custom code enumerating/adding InputType values; casting ints to InputType without validation.
Related errors
- Unexpected dashboard persistence mode
- Unexpected icon variant
- Unexpected MillisecondsDisplay value
- -32000
- Already connected to AppHost backchannel.
AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16).
Data as JSON: /api/errors/55661a01f2a03890.
Report an issue: GitHub.
Appendix: source
Thrown at src/Aspire.Hosting/Dashboard/DashboardService.cs:271
if (!string.IsNullOrEmpty(input.FileFilter))
{
dto.FileFilter = input.FileFilter;
}
dto.ValidationErrors.AddRange(input.ValidationErrors);
return dto;
}
internal static Aspire.DashboardService.Proto.V1.InputType MapInputType(Aspire.Hosting.InputType inputType)
{
return inputType switch
{
Aspire.Hosting.InputType.Text => Aspire.DashboardService.Proto.V1.InputType.Text,
Aspire.Hosting.InputType.SecretText => Aspire.DashboardService.Proto.V1.InputType.SecretText,
Aspire.Hosting.InputType.Choice => Aspire.DashboardService.Proto.V1.InputType.Choice,
Aspire.Hosting.InputType.Boolean => Aspire.DashboardService.Proto.V1.InputType.Boolean,
Aspire.Hosting.InputType.Number => Aspire.DashboardService.Proto.V1.InputType.Number,
Aspire.Hosting.InputType.File => Aspire.DashboardService.Proto.V1.InputType.File,
_ => throw new InvalidOperationException($"Unexpected input type: {inputType}"),
};
}
public static Aspire.Hosting.InputType MapInputType(Aspire.DashboardService.Proto.V1.InputType inputType)
{
return inputType switch
{
Aspire.DashboardService.Proto.V1.InputType.Text => InputType.Text,
Aspire.DashboardService.Proto.V1.InputType.SecretText => InputType.SecretText,
Aspire.DashboardService.Proto.V1.InputType.Choice => InputType.Choice,
Aspire.DashboardService.Proto.V1.InputType.Boolean => InputType.Boolean,
Aspire.DashboardService.Proto.V1.InputType.Number => InputType.Number,
Aspire.DashboardService.Proto.V1.InputType.File => InputType.File,
_ => throw new InvalidOperationException($"Unexpected input type: {inputType}"),
};
}
public override async Task WatchResources(View on GitHub (pinned to 25830f84bd)