microsoft/aspire · error · InvalidOperationException

File prompt input is missing a name.

Error message

File prompt input is missing a name.

What it means

File-type prompt inputs require a Name so the CLI can correlate the user's selected file(s) back to the input when completing the interaction. If a File input has a null or empty Name, HandleFileInputAsync cannot proceed and throws this InvalidOperationException.

Solutions

  1. Set Name on the PublishingPromptInput when InputType is File in the AppHost code
  2. Rebuild the AppHost after the fix and re-run the publish/prompt scenario

Example fix

// before
new PublishingPromptInput { InputType = InputType.File, Label = "Pick a config" }
// after
new PublishingPromptInput { Name = "configFile", InputType = InputType.File, Label = "Pick a config" }
Defensive patterns

Strategy: validation

Validate before calling

if (string.IsNullOrEmpty(input.Name))
    throw new ArgumentException("File prompt inputs require a Name.");

Type guard

static bool HasValidName(PublishingPromptInput i) => !string.IsNullOrEmpty(i.Name);

Try / catch

try { await HandleFileInputAsync(input, ...); }
catch (InvalidOperationException ex) when (ex.Message.Contains("missing a name")) { Console.Error.WriteLine("AppHost file input lacks Name."); }

Prevention

When it happens

Trigger: An AppHost sends a PublishingPromptInput with InputType File and Name null or empty during an interactive publish prompt.

Common situations: Custom publisher constructing a file input but forgetting to set the Name property; hand-built wire payloads in tests or custom tooling.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16). Data as JSON: /api/errors/c0ff0763e0275acd. Report an issue: GitHub.

Appendix: source

Thrown at src/Aspire.Cli/Commands/PipelineCommandBase.cs:1227

                return ValidationResult.Error("Please enter a valid number.");
            }

            return ValidationResult.Success();
        }

        return await InteractionService.PromptForStringAsync(
            promptText,
            binding: PromptBinding.CreateDefault(input.Value),
            validator: Validator,
            required: input.Required,
            cancellationToken: cancellationToken);
    }

    private async Task<string?> HandleFileInputAsync(PublishingPromptInput input, string promptText, IAppHostCliBackchannel backchannel, string interactionId, CancellationToken cancellationToken)
    {
        if (string.IsNullOrEmpty(input.Name))
        {
            throw new InvalidOperationException("File prompt input is missing a name.");
        }
        var inputName = input.Name;

        ValidationResult Validator(string value)
        {
            if (string.IsNullOrWhiteSpace(value))
            {
                return ValidationResult.Success();
            }

            string fullPath;
            try
            {
                fullPath = Path.GetFullPath(value);
            }
            catch (Exception ex) when (ex is ArgumentException or NotSupportedException or PathTooLongException)
            {
                return ValidationResult.Error("Please enter a valid file path.");

View on GitHub (pinned to 25830f84bd)