{"record":{"id":"57f59243adcf5777","repo":"chocolatey/choco","slug":"name-is-required-please-pass-in-a-name-for-the-ne","errorCode":null,"errorMessage":"Name is required. Please pass in a name for the new package.","messagePattern":"Name is required\\. Please pass in a name for the new package\\.","errorType":"validation","errorClass":"ApplicationException","httpStatus":null,"severity":"error","filePath":"src/chocolatey/infrastructure.app/commands/ChocolateyNewCommand.cs","lineNumber":109,"sourceCode":"                    var propValue = property[1].TrimSafe().UnquoteSafe();\r\n\r\n                    if (configuration.NewCommand.TemplateProperties.ContainsKey(propName))\r\n                    {\r\n                        this.Log().Warn(() => \"A value for '{0}' has already been added with the value '{1}'. Ignoring {0}='{2}'.\".FormatWith(propName, configuration.NewCommand.TemplateProperties[propName], propValue));\r\n                    }\r\n                    else\r\n                    {\r\n                        configuration.NewCommand.TemplateProperties.Add(propName, propValue);\r\n                    }\r\n                }\r\n            }\r\n        }\r\n\r\n        public virtual void Validate(ChocolateyConfiguration configuration)\r\n        {\r\n            if (string.IsNullOrWhiteSpace(configuration.NewCommand.Name))\r\n            {\r\n                throw new ApplicationException(\"Name is required. Please pass in a name for the new package.\");\r\n            }\r\n\r\n            if (configuration.NewCommand.Name.StartsWith(\"-file\", StringComparison.OrdinalIgnoreCase) || configuration.NewCommand.Name.StartsWith(\"--file\", StringComparison.OrdinalIgnoreCase))\r\n            {\r\n                throw new ApplicationException(@\"Automatic package creation from installer files only available in Business\r\n edition. See https://chocolatey.org/compare for details.\");\r\n            }\r\n        }\r\n\r\n        public virtual void HelpMessage(ChocolateyConfiguration configuration)\r\n        {\r\n            this.Log().Info(ChocolateyLoggers.Important, \"New Command\");\r\n            this.Log().Info(@\"\r\nChocolatey will generate package specification files for a new package.\r\n\");\r\n\r\n            \"chocolatey\".Log().Info(ChocolateyLoggers.Important, \"Usage\");\r\n            \"chocolatey\".Log().Info(@\"\r","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/chocolatey/choco/blob/0d5abdd10cc177a141e69547cad6935b419b6c17/src/chocolatey/infrastructure.app/commands/ChocolateyNewCommand.cs#L91-L127","documentation":"The new command generates a package skeleton and needs a package name. Validate() throws if configuration.NewCommand.Name is blank, because there is no identifier for the generated nuspec/folder. The name is resolved in ParseAdditionalArguments from the first non-flag, non-'key=value' positional token.","triggerScenarios":"Running 'choco new' with no positional name (only flags/properties like Version=1.0), or where every positional token starts with '-' or contains '='.","commonSituations":"Bare 'choco new'; scripts where the name variable is empty; passing only template properties without a name.","solutions":["Pass a name positionally: 'choco new MyPackage'.","In automation, assert the name variable is non-empty before invoking choco new.","Ensure the name token doesn't start with '-' or contain '=' so it is recognized as the name."],"exampleFix":"# before\nchoco new Version=1.0\n\n# after\nchoco new MyPackage Version=1.0","handlingStrategy":"validation","validationCode":"// Ensure a non-empty name before 'choco new'.\nif (string.IsNullOrWhiteSpace(name) || name.StartsWith(\"-\") || name.Contains(\"=\"))\n{\n    throw new InvalidOperationException(\"choco new requires a package name (no leading '-', no '=')\");\n}\nRunChoco($\"new {name}\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass a plain package name as the first positional token to 'choco new'.","Don't lead the command with template properties (Version=...); put the name first.","Assert the name variable is non-empty in automation."],"tags":["new","validation","name","package-creation"],"backgroundTag":null,"analyzedSha":"0d5abdd10cc177a141e69547cad6935b419b6c17","analyzedAt":"2026-08-13T18:33:03.301Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}