{"record":{"id":"90800d39fe1ec78a","repo":"abpframework/abp","slug":"apikeyresult-errormessage","errorCode":null,"errorMessage":"{apiKeyResult.ErrorMessage}","messagePattern":"\\{apiKeyResult\\.ErrorMessage\\}","errorType":"exception","errorClass":"UserFriendlyException","httpStatus":null,"severity":"error","filePath":"framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/TemplateProjectBuilder.cs","lineNumber":119,"sourceCode":"        }\n\n        if (apiKeyResult == null)\n        {\n            apiKeyResult = await ApiKeyService.GetApiKeyOrNullAsync();\n        }\n#else\n            apiKeyResult = await ApiKeyService.GetApiKeyOrNullAsync();\n#endif\n\n        if (apiKeyResult != null)\n        {\n            if (apiKeyResult.ApiKey != null)\n            {\n                args.ExtraProperties[\"api-key\"] = apiKeyResult.ApiKey;\n            }\n            else if (templateInfo.Name == AppProTemplate.TemplateName)\n            {\n                throw new UserFriendlyException(apiKeyResult.ErrorMessage);\n            }\n        }\n\n        if (apiKeyResult?.LicenseCode != null)\n        {\n            args.ExtraProperties[\"license-code\"] = apiKeyResult.LicenseCode;\n        }\n\n        var context = new ProjectBuildContext(\n            templateInfo,\n            null,\n            null,\n            null,\n            templateFile,\n            args\n        );\n\n        if (context.Template is AppTemplateBase appTemplateBase)","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/abpframework/abp/blob/7ed43b1931b9df46a50c0c59148a18645641d0df/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/TemplateProjectBuilder.cs#L101-L137","documentation":"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.","triggerScenarios":"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.","commonSituations":"See trigger scenarios.","solutions":["Ensure you are logged in ('abp login <email>') with an account that has an active ABP Commercial/Pro license.","Verify the license is assigned to your user in the ABP account portal (organization licenses must be explicitly allocated).","Renew an expired Pro subscription, then re-run 'abp new -t app-pro'.","If you do not need Pro features, switch to the free 'app' template."],"exampleFix":"// before\nabp new Acme.Pro -t app-pro   // logged in as free user\n// after\nabp login pro-user@example.com   // account with active Pro license\nabp new Acme.Pro -t app-pro","handlingStrategy":"validation","validationCode":"var apiKey = await ApiKeyService.GetApiKeyOrNullAsync();\nif (apiKey?.ApiKey == null && templateInfo.Name == AppProTemplate.TemplateName)\n{\n    Console.Error.WriteLine($\"Cannot create Pro template: {apiKey?.ErrorMessage ?? \"no API key\"}\");\n    return;\n}","typeGuard":null,"tryCatchPattern":"try { await builder.BuildAsync(args); }\ncatch (UserFriendlyException ex) when (args.TemplateName == AppProTemplate.TemplateName)\n{ Console.Error.WriteLine($\"Pro creation failed: {ex.Message}\"); }","preventionTips":["Pre-flight check the license before invoking 'abp new -t app-pro' in CI.","Keep the Pro account credentials in a secure store and verify login before automated runs."],"tags":["cli","licensing","pro-template","api-key","authentication"],"backgroundTag":null,"analyzedSha":"7ed43b1931b9df46a50c0c59148a18645641d0df","analyzedAt":"2026-08-13T16:26:11.351Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}