{"record":{"id":"f4928917f2bc0e2e","repo":"chocolatey/choco","slug":"license-is-missing-or-invalid","errorCode":null,"errorMessage":"License is missing or invalid.","messagePattern":"License is missing or invalid\\.","errorType":"exception","errorClass":"ApplicationException","httpStatus":null,"severity":"error","filePath":"src/chocolatey/infrastructure.app/runners/GenericRunner.cs","lineNumber":170,"sourceCode":"\r\n                    this.Log().Debug(\"Including sources from chocolatey.config file.\");\r\n                }\r\n            }\r\n        }\r\n\r\n        public void FailOnMissingOrInvalidLicenseIfFeatureSet(ChocolateyConfiguration config)\r\n        {\r\n            if (!config.Features.FailOnInvalidOrMissingLicense ||\r\n                config.CommandName.TrimSafe().IsEqualTo(\"feature\") ||\r\n                config.CommandName.TrimSafe().IsEqualTo(\"features\")\r\n            )\r\n            {\r\n                return;\r\n            }\r\n\r\n            if (!config.Information.IsLicensedVersion)\r\n            {\r\n                throw new ApplicationException(\"License is missing or invalid.\");\r\n            }\r\n        }\r\n\r\n        public void Run(ChocolateyConfiguration config, Container container, bool isConsole, Action<ICommand> parseArgs)\r\n        {\r\n            var tasks = container.GetAllInstances<ITask>();\r\n            foreach (var task in tasks)\r\n            {\r\n                task.Initialize();\r\n            }\r\n\r\n            FailOnMissingOrInvalidLicenseIfFeatureSet(config);\r\n            HttpsSecurity.Reset();\r\n            EventManager.Publish(new PreRunMessage(config));\r\n\r\n            try\r\n            {\r\n                var command = FindCommand(config, container, isConsole, parseArgs);\r","sourceCodeStart":152,"sourceCodeEnd":188,"githubUrl":"https://github.com/chocolatey/choco/blob/0d5abdd10cc177a141e69547cad6935b419b6c17/src/chocolatey/infrastructure.app/runners/GenericRunner.cs#L152-L188","documentation":"Thrown by GenericRunner.FailOnMissingOrInvalidLicenseIfFeatureSet when the configuration.Features.FailOnInvalidOrMissingLicense flag is enabled, the command is not 'feature'/'features', and config.Information.IsLicensedVersion is false. This feature flag makes Chocolatey fail hard (rather than silently degrade) when licensed functionality is expected but no valid license is present. The feature/'features' command is exempt so users can always manage features including this one.","triggerScenarios":"The 'failOnInvalidOrMissingLicense' feature is enabled and the user runs any command other than 'feature'/'features' without a valid Chocolatey license installed. The license file is missing, expired, or corrupted. The license check in Information.IsLicensedVersion returns false due to no license being loaded.","commonSituations":"Enterprise environment mandates licensed features but the license expired or wasn't deployed to this machine. User enabled the fail-on-license feature as a safety measure but then the license lapsed. Machine was provisioned without the license file. License was installed for a different Chocolatey edition.","solutions":["Install or renew a valid Chocolatey license file in the expected location","If the license is not needed, disable the feature: 'choco feature disable --name=failOnInvalidOrMissingLicense'","Use 'choco feature' command (which is exempt) to manage the setting regardless of license state","Verify the license file path and format match what Chocolatey expects"],"exampleFix":"// before: feature is enabled, no license\nchoco install mypackage\n// throws: License is missing or invalid.\n\n// after: disable the strict check (always works since 'feature' is exempt)\nchoco feature disable --name=failOnInvalidOrMissingLicense\nchoco install mypackage","handlingStrategy":"validation","validationCode":"// Check license and feature flag before running\nif (config.Features.FailOnInvalidOrMissingLicense &&\n    !config.Information.IsLicensedVersion &&\n    !config.CommandName.IsEqualTo(\"feature\") &&\n    !config.CommandName.IsEqualTo(\"features\"))\n{\n    Console.Error.WriteLine(\"License required (failOnInvalidOrMissingLicense is enabled). \" +\n        \"Disable with: choco feature disable --name=failOnInvalidOrMissingLicense\");\n    return;\n}","typeGuard":"public static bool CanRunWithoutLicense(ChocolateyConfiguration config)\n{\n    if (!config.Features.FailOnInvalidOrMissingLicense) return true;\n    if (config.CommandName.TrimSafe().IsEqualTo(\"feature\") ||\n        config.CommandName.TrimSafe().IsEqualTo(\"features\")) return true;\n    return config.Information.IsLicensedVersion;\n}","tryCatchPattern":"try\n{\n    runner.FailOnMissingOrInvalidLicenseIfFeatureSet(config);\n}\ncatch (ApplicationException ex) when (ex.Message.Contains(\"License is missing\"))\n{\n    logger.Error(\"No valid license. Disable failOnInvalidOrMissingLicense or install a license.\");\n    // 'choco feature disable --name=failOnInvalidOrMissingLicense' always works\n}","preventionTips":["Ensure valid license files are deployed before enabling failOnInvalidOrMissingLicense","Remember that 'choco feature' commands are exempt and can always manage the setting","Monitor license expiration dates in enterprise environments","Have a fallback plan to disable the feature if the license lapses unexpectedly"],"tags":["licensing","feature-flag","configuration","license-validation"],"backgroundTag":null,"analyzedSha":"0d5abdd10cc177a141e69547cad6935b419b6c17","analyzedAt":"2026-08-13T18:33:03.301Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}