{"record":{"id":"c62a16075c129b9d","repo":"microsoft/aspire","slug":"the-0-option-must-be-specified-when-running-in-non-c62a16","errorCode":null,"errorMessage":"The {0} option must be specified when running in non-interactive mode.","messagePattern":"The (.+?) option must be specified when running in non-interactive mode\\.","errorType":"exception","errorClass":"NonInteractiveException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Cli/Interaction/ConsoleInteractionService.cs","lineNumber":813,"sourceCode":"            if (match is null)\n            {\n                return null; // Signal that matching failed\n            }\n            // MatchChoice returns the instance from the choices list via FirstOrDefault,\n            // so reference equality is correct here for deduplication.\n            if (!matched.Contains(match))\n            {\n                matched.Add(match);\n            }\n        }\n        return matched;\n    }\n\n    [DoesNotReturn]\n    private void ThrowNonInteractiveError(string symbolDisplayName)\n    {\n        DisplayError(string.Format(CultureInfo.CurrentCulture, InteractionServiceStrings.NonInteractiveOptionRequired, symbolDisplayName));\n        throw new NonInteractiveException(symbolDisplayName);\n    }\n\n    internal void ValidateResolvedStringValue(string value, bool required, Func<string, ValidationResult>? validator, string symbolDisplayName)\n    {\n        if (required && string.IsNullOrEmpty(value))\n        {\n            ThrowNonInteractiveError(symbolDisplayName);\n        }\n\n        if (validator is not null)\n        {\n            var result = validator(value);\n            if (!result.Successful)\n            {\n                DisplayError(result.Message ?? string.Format(CultureInfo.CurrentCulture, InteractionServiceStrings.NonInteractiveInvalidValue, value, symbolDisplayName));\n                throw new NonInteractiveException(symbolDisplayName);\n            }\n        }","sourceCodeStart":795,"sourceCodeEnd":831,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Cli/Interaction/ConsoleInteractionService.cs#L795-L831","documentation":"ThrowNonInteractiveError is the shared failure path for prompts in non-interactive mode: it first displays a localized error stating that the given option (symbol display name) must be specified, then throws NonInteractiveException carrying that option name. BaseCommand catches NonInteractiveException and converts it into the command's exit result.","triggerScenarios":"Any ConsoleInteractionService prompt method invoked without interactive input while the prompt symbol has no non-interactive default; the symbol display name names the option the user should have passed.","commonSituations":"CI runs missing a required flag that mirrors an interactive prompt; new prompts added without a non-interactive counterpart option; users piping commands expecting prompts to auto-resolve.","solutions":["Specify the named option on the command line, exactly as shown in the error message.","Add a non-interactive default value binding for the prompt so the throw is not reached.","Catch NonInteractiveException at the command boundary (as BaseCommand does) to render a clean exit message.","Test commands with --non-interactive to find prompts lacking option bindings before shipping."],"exampleFix":"// before\n// error: The --environment option must be specified when running in non-interactive mode.\naspire deploy --non-interactive\n// after\naspire deploy --non-interactive --environment production","handlingStrategy":"try-catch","validationCode":"if (!hostEnvironment.SupportsInteractiveOutput && optionValue is null)\n{\n    interaction.DisplayError($\"The {optionName} option must be specified when running in non-interactive mode.\");\n    return ExitCodeConstants.InvalidCommandUsage;\n}","typeGuard":null,"tryCatchPattern":"try { await command.ExecuteAsync(context); }\ncatch (NonInteractiveException ex)\n{\n    interaction.DisplayError($\"The {ex.OptionName} option must be specified when running in non-interactive mode.\");\n    return ExitCodeConstants.InvalidCommandUsage;\n}","preventionTips":["Mirror every interactive prompt with a command-line option.","Catch NonInteractiveException in BaseCommand-style boundaries for clean exits.","Include the option name in the error so users know what to pass.","Test each command with --non-interactive and no options."],"tags":["cli","non-interactive","prompt","missing-option"],"backgroundTag":"missing-required-option","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"}