abpframework/abp · error · UserFriendlyException

{apiKeyResult.ErrorMessage}

Error message

{apiKeyResult.ErrorMessage}

What it means

In BuildAsync, after attempting to obtain a NuGet API key via ApiKeyService, if the result is non-null but has no ApiKey AND the requested template is AppProTemplate, the result's ErrorMessage is re-thrown as a UserFriendlyException. Pro template generation requires a valid API key to restore private packages, so the failure is fatal for the Pro template but tolerated for non-Pro.

Source

Thrown at framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/TemplateProjectBuilder.cs:119

        }

        if (apiKeyResult == null)
        {
            apiKeyResult = await ApiKeyService.GetApiKeyOrNullAsync();
        }
#else
            apiKeyResult = await ApiKeyService.GetApiKeyOrNullAsync();
#endif

        if (apiKeyResult != null)
        {
            if (apiKeyResult.ApiKey != null)
            {
                args.ExtraProperties["api-key"] = apiKeyResult.ApiKey;
            }
            else if (templateInfo.Name == AppProTemplate.TemplateName)
            {
                throw new UserFriendlyException(apiKeyResult.ErrorMessage);
            }
        }

        if (apiKeyResult?.LicenseCode != null)
        {
            args.ExtraProperties["license-code"] = apiKeyResult.LicenseCode;
        }

        var context = new ProjectBuildContext(
            templateInfo,
            null,
            null,
            null,
            templateFile,
            args
        );

        if (context.Template is AppTemplateBase appTemplateBase)

View on GitHub (pinned to 7ed43b1931)

Solutions

  1. Ensure you are logged in ('abp login <email>') with an account that has an active ABP Commercial/Pro license.
  2. Verify the license is assigned to your user in the ABP account portal (organization licenses must be explicitly allocated).
  3. Renew an expired Pro subscription, then re-run 'abp new -t app-pro'.
  4. If you do not need Pro features, switch to the free 'app' template.

Example fix

// before
abp new Acme.Pro -t app-pro   // logged in as free user
// after
abp login pro-user@example.com   // account with active Pro license
abp new Acme.Pro -t app-pro
Defensive patterns

Strategy: validation

Validate before calling

var apiKey = await ApiKeyService.GetApiKeyOrNullAsync();
if (apiKey?.ApiKey == null && templateInfo.Name == AppProTemplate.TemplateName)
{
    Console.Error.WriteLine($"Cannot create Pro template: {apiKey?.ErrorMessage ?? "no API key"}");
    return;
}

Try / catch

try { await builder.BuildAsync(args); }
catch (UserFriendlyException ex) when (args.TemplateName == AppProTemplate.TemplateName)
{ Console.Error.WriteLine($"Pro creation failed: {ex.Message}"); }

Prevention

When it happens

Trigger: Requesting the 'app-pro' template while the API-key retrieval returns an error (no license, expired license, license not linked to account, network failure during key issuance). Non-Pro templates skip the throw because the key is optional.

Common situations: See trigger scenarios.

Related errors


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