abpframework/abp · error · CliUsageException

Module name: {args.Module} is invalid

Error message

Module name: {args.Module} is invalid

What it means

Thrown by the ABP CLI proxy generator when the --module argument does not match any module key in the application's API description model (the /api/abp/api-definition payload fetched from args.Url). The lookup is case-insensitive (CurrentCultureIgnoreCase), so only a spelling mismatch or a module that simply is not exposed would cause a null result. This is a CliUsageException, meaning it signals bad CLI input rather than an internal failure.

Source

Thrown at framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ServiceProxying/ServiceProxyGeneratorBase.cs:43

        JsonSerializer = jsonSerializer;
        Logger = NullLogger<T>.Instance;
    }

    public abstract Task GenerateProxyAsync(GenerateProxyArgs args);

    protected virtual async Task<ApplicationApiDescriptionModel> GetApplicationApiDescriptionModelAsync(GenerateProxyArgs args, ApplicationApiDescriptionModelRequestDto requestDto = null)
    {
        Check.NotNull(args.Url, nameof(args.Url));

        var client = CliHttpClientFactory.CreateClient(needsAuthentication: false);

        var apiDefinitionResult = await client.GetStringAsync(CliUrls.GetApiDefinitionUrl(args.Url, requestDto));
        var apiDefinition = JsonSerializer.Deserialize<ApplicationApiDescriptionModel>(apiDefinitionResult);

        var moduleDefinition = apiDefinition.Modules.FirstOrDefault(x => string.Equals(x.Key, args.Module, StringComparison.CurrentCultureIgnoreCase)).Value;
        if (moduleDefinition == null)
        {
            throw new CliUsageException($"Module name: {args.Module} is invalid");
        }

        var serviceType = GetServiceType(args);
        switch (serviceType)
        {
            case ServiceType.Application:
                moduleDefinition.Controllers.RemoveAll(x => x.Value.IsIntegrationService);
                break;
            case ServiceType.Integration:
                moduleDefinition.Controllers.RemoveAll(x => !x.Value.IsIntegrationService);
                break;
        }

        var apiDescriptionModel = ApplicationApiDescriptionModel.Create();
        apiDescriptionModel.Types = apiDefinition.Types;
        apiDescriptionModel.AddModule(moduleDefinition);
        return apiDescriptionModel;
    }

View on GitHub (pinned to 7ed43b1931)

Solutions

  1. Open <serverUrl>/api/abp/api-definition in a browser and copy the exact module key (top-level object key under modules) to use as --module.
  2. Drop the --module argument entirely if you want proxies for all modules, which bypasses the single-module filter.
  3. Verify the server is running and reachable from the CLI, and that it is an ABP application exposing the api-definition endpoint.
  4. Make sure you target an ABP server version whose module names match what you expect (module keys can change between major versions).

Example fix

// before
abp generate-proxy -t csharp -u https://localhost:44300 -m MyApp

// after (use the exact module key from /api/abp/api-definition, e.g. "app")
abp generate-proxy -t csharp -u https://localhost:44300 -m app

// or omit --module to generate for all modules
abp generate-proxy -t csharp -u https://localhost:44300
Defensive patterns

Strategy: validation

Validate before calling

// Fetch the API definition and confirm the module key before running generate-proxy
using var http = new HttpClient();
var json = await http.GetStringAsync($"{serverUrl.TrimEnd('/')}/api/abp/api-definition");
using var doc = JsonDocument.Parse(json);
var keys = doc.RootElement.GetProperty("modules").EnumerateObject().Select(p => p.Name).ToList();
if (!keys.Any(k => k.Equals(moduleName, StringComparison.OrdinalIgnoreCase)))
    throw new InvalidOperationException($"Module '{moduleName}' not in: {string.Join(", ", keys)}");

Prevention

When it happens

Trigger: Running `abp generate-proxy -t csharp -m <Module> --url <serverUrl>` (or the Application/Integration/JavaScript variants) where <Module> is not among the keys in apiDefinition.Modules. Also triggered if the fetched API definition is empty/malformed so no modules are present.

Common situations: Typo in the module name; passing the .NET project name instead of the ABP module key; targeting a server URL whose API definition was filtered or that runs an older ABP version exposing different module names; specifying --module when the target app only has a single default module under a different key.

Related errors


AI-assisted analysis of abpframework/abp@7ed43b1931 (2026-08-13). Data as JSON: /api/errors/5677de86736ebae5. Report an issue: GitHub.