chocolatey/choco · error · InvalidDataException

One or more issues found with {0}, please fix all validation

Error message

One or more issues found with {0}, please fix all validation items above listed as errors.

What it means

Thrown as InvalidDataException after running nuspec validation rules (e.g. during choco pack / template validation) once hasErrors is true because at least one rule reported an error severity. The message points at the nuspec file path and instructs fixing every item logged above as an error.

Source

Thrown at src/chocolatey/infrastructure.app/services/NugetService.cs:2291

                        break;

                    case infrastructure.rules.RuleType.Note:
                        this.Log().Info("NOTE: " + message);

                        if (!string.IsNullOrEmpty(rule.HelpUrl))
                        {
                            this.Log().Info("      See {0}", rule.HelpUrl);
                        }

                        break;
                }
            }

            if (hasErrors)
            {
                this.Log().Info(string.Empty);
                throw new InvalidDataException("One or more issues found with {0}, please fix all validation items above listed as errors.".FormatWith(nuspecFilePath));
            }
        }

        private string GetInstallDirectory(IPackageMetadata installedPackage)
        {
            var pathResolver = NugetCommon.GetPathResolver(_fileSystem);
            var installDirectory = pathResolver.GetInstallPath(new PackageIdentity(installedPackage.Id, installedPackage.Version));

            if (!_fileSystem.DirectoryExists(installDirectory))
            {
                return null;
            }

            return installDirectory;
        }

        protected virtual void EnsurePackageFilesHaveCompatibleAttributes(ChocolateyConfiguration config, IPackageMetadata installedPackage)
        {

View on GitHub (pinned to 0d5abdd10c)

Solutions

  1. Read every validation error logged immediately above the exception and fix each item marked 'error'
  2. Ensure required metadata elements (id, version, description, authors) are present and valid
  3. Run choco pack with --verbose to surface all failed rules
  4. Diff against a known-good nuspec template to find the offending element

Example fix

// before
<metadata><id>MyPkg</id><version>1.0</version></metadata>
// after
<metadata><id>MyPkg</id><version>1.0.0</version><authors>Me</authors><description>Desc</description></metadata>
Defensive patterns

Strategy: validation

Validate before calling

// Pre-validate the nuspec with the same rules before packing.
var rules = new NuspecRuleValidator();
var results = rules.Validate(nuspecFilePath);
if (results.Any(r => r.RuleType == RuleType.Error)) {
    foreach (var r in results.Where(r => r.RuleType == RuleType.Error)) Console.Error.WriteLine(r.Message);
    return; // fix metadata, do not attempt pack
}

Try / catch

try { choco.Pack(nuspecPath); }
catch (InvalidDataException ex) when (ex.Message.Contains("validation items above listed as errors")) {
    // re-run validation and surface every failing rule for the user
    logger.Error(ex.Message);
}

Prevention

When it happens

Trigger: Calling nuspec rule validation on a .nuspec where at least one IValidationRule reports RuleType.Error; hasErrors flips true and the throw fires with the nuspec file path.

Common situations: A nuspec missing required metadata (id/version/description/authors); an invalid semantic version; malformed licenseUrl/projectUrl/iconUrl; element values failing rule checks during pack.

Related errors


AI-assisted analysis of chocolatey/choco@0d5abdd10c (2026-08-13). Data as JSON: /api/errors/27dc298c1bbb887e. Report an issue: GitHub.