{"record":{"id":"c0ff0763e0275acd","repo":"microsoft/aspire","slug":"file-prompt-input-is-missing-a-name","errorCode":null,"errorMessage":"File prompt input is missing a name.","messagePattern":"File prompt input is missing a name\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Cli/Commands/PipelineCommandBase.cs","lineNumber":1227,"sourceCode":"                return ValidationResult.Error(\"Please enter a valid number.\");\n            }\n\n            return ValidationResult.Success();\n        }\n\n        return await InteractionService.PromptForStringAsync(\n            promptText,\n            binding: PromptBinding.CreateDefault(input.Value),\n            validator: Validator,\n            required: input.Required,\n            cancellationToken: cancellationToken);\n    }\n\n    private async Task<string?> HandleFileInputAsync(PublishingPromptInput input, string promptText, IAppHostCliBackchannel backchannel, string interactionId, CancellationToken cancellationToken)\n    {\n        if (string.IsNullOrEmpty(input.Name))\n        {\n            throw new InvalidOperationException(\"File prompt input is missing a name.\");\n        }\n        var inputName = input.Name;\n\n        ValidationResult Validator(string value)\n        {\n            if (string.IsNullOrWhiteSpace(value))\n            {\n                return ValidationResult.Success();\n            }\n\n            string fullPath;\n            try\n            {\n                fullPath = Path.GetFullPath(value);\n            }\n            catch (Exception ex) when (ex is ArgumentException or NotSupportedException or PathTooLongException)\n            {\n                return ValidationResult.Error(\"Please enter a valid file path.\");","sourceCodeStart":1209,"sourceCodeEnd":1245,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Cli/Commands/PipelineCommandBase.cs#L1209-L1245","documentation":"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.","triggerScenarios":"An AppHost sends a PublishingPromptInput with InputType File and Name null or empty during an interactive publish prompt.","commonSituations":"Custom publisher constructing a file input but forgetting to set the Name property; hand-built wire payloads in tests or custom tooling.","solutions":["Set Name on the PublishingPromptInput when InputType is File in the AppHost code","Rebuild the AppHost after the fix and re-run the publish/prompt scenario"],"exampleFix":"// before\nnew PublishingPromptInput { InputType = InputType.File, Label = \"Pick a config\" }\n// after\nnew PublishingPromptInput { Name = \"configFile\", InputType = InputType.File, Label = \"Pick a config\" }","handlingStrategy":"validation","validationCode":"if (string.IsNullOrEmpty(input.Name))\n    throw new ArgumentException(\"File prompt inputs require a Name.\");","typeGuard":"static bool HasValidName(PublishingPromptInput i) => !string.IsNullOrEmpty(i.Name);","tryCatchPattern":"try { await HandleFileInputAsync(input, ...); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"missing a name\")) { Console.Error.WriteLine(\"AppHost file input lacks Name.\"); }","preventionTips":["Always set Name on PublishingPromptInput, especially File inputs","Validate prompt definitions in AppHost unit tests","Keep prompt-creation helpers that require name parameters"],"tags":["cli","prompt","file-input"],"backgroundTag":"missing-required-argument","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T09:17:21.228Z"}