{"record":{"id":"124279a5ab6e2d15","repo":"abpframework/abp","slug":"angular-library-name-can-not-be-empty","errorCode":null,"errorMessage":"Angular library name can not be empty","messagePattern":"Angular library name can not be empty","errorType":"exception","errorClass":"CliUsageException","httpStatus":null,"severity":"error","filePath":"framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/ProjectCreationCommandBase.cs","lineNumber":796,"sourceCode":"        var libraryName = projectArgs.SolutionName.ProjectName.ToKebabCase();\n        var angularAppPath = Path.Combine(rootPath, \"apps\", \"angular\");\n\n        var result = await CreateAngularLibraryAsync(libraryName, angularAppPath);\n\n        Logger.LogInformation(result);\n    }\n\n    protected virtual async Task<string> CreateAngularLibraryAsync(\n        string libraryName,\n        string workingDirectory,\n        bool isSecondaryEndpoint = false,\n        bool isModuleTemplate = true,\n        bool isOverride = true)\n    {\n        //TODO: Can we improve this validations ?\n        if (string.IsNullOrWhiteSpace(libraryName))\n        {\n            throw new CliUsageException(\"Angular library name can not be empty\");\n        }\n\n        if (string.IsNullOrWhiteSpace(workingDirectory))\n        {\n            throw new CliUsageException(\"Angular project path can not be empty\");\n        }\n\n        var commandBuilder = new StringBuilder($\"npx ng g @abp/ng.schematics:create-lib --package-name {libraryName}\");\n\n        commandBuilder.Append($\" --is-secondary-entrypoint {isSecondaryEndpoint.ToString().ToLowerInvariant()}\");\n        commandBuilder.Append($\" --is-module-template {isModuleTemplate.ToString().ToLowerInvariant()}\");\n        commandBuilder.Append($\" --override {isOverride.ToString().ToLowerInvariant()}\");\n\n        var result = CmdHelper.RunCmdAndGetOutput(commandBuilder.ToString(), workingDirectory);\n        return await Task.FromResult(result);\n    }\n\n    public static class Options","sourceCodeStart":778,"sourceCodeEnd":814,"githubUrl":"https://github.com/abpframework/abp/blob/7ed43b1931b9df46a50c0c59148a18645641d0df/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/ProjectCreationCommandBase.cs#L778-L814","documentation":"Thrown by ProjectCreationCommandBase.CreateAngularLibraryAsync when the libraryName parameter is null or whitespace. This method generates an Angular library using the ABP schematics (npx ng g @abp/ng.schematics:create-lib) and requires a valid package name. The code marks the validation with a TODO suggesting it could be improved.","triggerScenarios":"Calling CreateAngularLibraryAsync with an empty/null library name. This typically happens when the caller derives the library name from a module or entity name that was not provided, or from a template variable that resolved to empty.","commonSituations":"During module template generation where the module/entity name is missing or empty, causing the derived Angular library name to be empty. Also from programmatic API misuse where the caller does not validate before invoking. The TODO comment indicates the validation is considered incomplete.","solutions":["Ensure the module or entity name (from which the Angular library name is derived) is provided and non-empty","Pass an explicit, non-empty library name that follows npm package naming conventions (e.g., @mycompany/my-lib)","Check upstream: if the name comes from commandLineArgs.Target or a module parameter, ensure that was supplied"],"exampleFix":"// before\nawait CreateAngularLibraryAsync(\"\", workingDir);\n\n// after\nawait CreateAngularLibraryAsync(\"@mycompany/feature-lib\", workingDir);","handlingStrategy":"validation","validationCode":"// Validate the Angular library name before calling CreateAngularLibraryAsync\nif (string.IsNullOrWhiteSpace(libraryName))\n{\n    Console.Error.WriteLine(\"Error: Angular library name cannot be empty. Derive it from the module name.\");\n    return;\n}\n// Also validate npm package name format\nif (!Regex.IsMatch(libraryName, @\"^(@[a-z0-9-~][a-z0-9-._~]*/)?[a-z0-9-~][a-z0-9-._~]*$\"))\n{\n    Console.Error.WriteLine($\"Error: '{libraryName}' is not a valid npm package name.\");\n    return;\n}","typeGuard":"// Type guard for non-empty, npm-valid library name\nstatic bool IsValidAngularLibraryName(string? name) =>\n    !string.IsNullOrWhiteSpace(name) &&\n    Regex.IsMatch(name, @\"^(@[a-z0-9-~][a-z0-9-._~]*/)?[a-z0-9-~][a-z0-9-._~]*$\");","tryCatchPattern":"try\n{\n    await CreateAngularLibraryAsync(libraryName, workingDirectory);\n}\ncatch (CliUsageException ex) when (ex.Message.Contains(\"Angular library name can not be empty\"))\n{\n    logger.LogError(\"Library name was empty. Ensure the module/entity name is provided.\");\n}","preventionTips":["Ensure the module or entity name (source of the library name) is provided and non-empty","Validate the name follows npm package naming conventions before passing it","Guard the upstream call site that derives the library name from user input"],"tags":["cli","abp-cli","validation","angular","project-creation"],"backgroundTag":null,"analyzedSha":"7ed43b1931b9df46a50c0c59148a18645641d0df","analyzedAt":"2026-08-13T16:26:11.351Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}