abpframework/abp · error · CliUsageException
Option Type value is invalid
Error message
Option Type value is invalid
What it means
Thrown by ProxyCommandBase.ExecuteAsync when the -t/--type value IS provided but does not match any key in ServiceProxyOptions.Generators. The value is uppercased (ToUpperInvariant) before lookup, so 'CSharp', 'CSHARP', 'csharp' all resolve to 'CSHARP'. The Generators dictionary is populated from AbpCliServiceProxyOptions configuration, which by default includes CSHARP, JS, and NG generators.
Source
Thrown at framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/ProxyCommandBase.cs:47
ServiceScopeFactory = serviceScopeFactory;
ServiceProxyOptions = serviceProxyOptions.Value;
Logger = NullLogger<T>.Instance;
}
public async Task ExecuteAsync(CommandLineArgs commandLineArgs)
{
var generateType = commandLineArgs.Options.GetOrNull(Options.GenerateType.Short, Options.GenerateType.Long)?.ToUpperInvariant();
if (string.IsNullOrWhiteSpace(generateType))
{
throw new CliUsageException("Option Type is required" +
Environment.NewLine +
GetUsageInfo());
}
if (!ServiceProxyOptions.Generators.ContainsKey(generateType))
{
throw new CliUsageException("Option Type value is invalid" +
Environment.NewLine +
GetUsageInfo());
}
using (var scope = ServiceScopeFactory.CreateScope())
{
var generatorType = ServiceProxyOptions.Generators[generateType];
var serviceProxyGenerator = scope.ServiceProvider.GetService(generatorType).As<IServiceProxyGenerator>();
await serviceProxyGenerator.GenerateProxyAsync(BuildArgs(commandLineArgs));
}
}
private GenerateProxyArgs BuildArgs(CommandLineArgs commandLineArgs)
{
var url = commandLineArgs.Options.GetOrNull(Options.Url.Short, Options.Url.Long);
var target = commandLineArgs.Options.GetOrNull(Options.Target.Long);
var module = commandLineArgs.Options.GetOrNull(Options.Module.Short, Options.Module.Long) ?? "app";View on GitHub (pinned to 7ed43b1931)
Solutions
- Use one of the valid type values: csharp, js, or ng
- Run 'abp help generate-proxy' to confirm valid type values for your ABP version
- If using a custom generator, register it in AbpCliServiceProxyOptions.Generators before calling ExecuteAsync
Example fix
// before abp generate-proxy -t typescript -m app // after abp generate-proxy -t csharp -m app
Defensive patterns
Strategy: validation
Validate before calling
// Validate type value against known generators before invoking
var validTypes = new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "csharp", "js", "ng" };
var typeOption = commandLineArgs.Options.GetOrNull("t", "type");
if (typeOption != null && !validTypes.Contains(typeOption))
{
Console.Error.WriteLine($"Error: '{typeOption}' is not a valid type. Use: {string.Join(", ", validTypes)}");
return;
} Type guard
// Type guard for valid proxy generation types
public static bool IsValidProxyType(string type)
{
return type != null &&
new[] { "csharp", "js", "ng" }.Contains(type, StringComparer.OrdinalIgnoreCase);
} Try / catch
try
{
await proxyCommand.ExecuteAsync(commandLineArgs);
}
catch (CliUsageException ex) when (ex.Message.Contains("Option Type value is invalid"))
{
Console.Error.WriteLine($"Invalid type. Valid values: csharp, js, ng");
} Prevention
- Memorize the three valid types: csharp, js, ng
- Use tab-completion or shell scripts that constrain type choices
- Check the Generators dictionary keys if extending with custom generators
When it happens
Trigger: Passing an unrecognized type string like 'abp generate-proxy -t typescript' or '-t java' or '-t python'. The ContainsKey check on the Generators dictionary returns false.
Common situations: Typo in the type name (e.g., 'c-sharp' instead of 'csharp'), guessing at supported types, or a custom proxy generator that hasn't been registered in AbpCliServiceProxyOptions.
Related errors
- Option Type is required
- Invalid Suite command! Run "abp help suite" command to see a
- Local paths are not specified!
- Target culture is missing!
- Should specify an option name after '--' prefix!
AI-assisted analysis of abpframework/abp@7ed43b1931 (2026-08-13).
Data as JSON: /api/errors/8f082bb53f68a2d4.
Report an issue: GitHub.