{"record":{"id":"13662e08bd4557ed","repo":"puppetlabs/puppet","slug":"cannot-have-both-ensure-disabled-and-flavor","errorCode":null,"errorMessage":"Cannot have both `ensure => disabled` and `flavor`","messagePattern":"Cannot have both `ensure => disabled` and `flavor`","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/puppet/type/package.rb","lineNumber":421,"sourceCode":"          super(currentvalue)\n        end\n      end\n\n      def change_to_s(currentvalue, newvalue)\n        if provider.respond_to?(:package_settings_change_to_s)\n          provider.package_settings_change_to_s(currentvalue, newvalue)\n        else\n          super(currentvalue, newvalue)\n        end\n      end\n    end\n\n    newproperty(:flavor, :required_features => :supports_flavors) do\n      desc \"OpenBSD and DNF modules support 'flavors', which are\n        further specifications for which type of package you want.\"\n      validate do |value|\n        if [:disabled, \"disabled\"].include?(@resource[:ensure]) && value\n          raise ArgumentError, _('Cannot have both `ensure => disabled` and `flavor`')\n        end\n      end\n    end\n\n    newparam(:source) do\n      desc \"Where to find the package file. This is mostly used by providers that don't\n        automatically download packages from a central repository. (For example:\n        the `yum` provider ignores this attribute, `apt` provider uses it if present\n        and the `rpm` and `dpkg` providers require it.)\n\n        Different providers accept different values for `source`. Most providers\n        accept paths to local files stored on the target system. Some providers\n        may also accept URLs or network drive paths. Puppet will not\n        automatically retrieve source files for you, and usually just passes the\n        value of `source` to the package installation command.\n\n        You can use a `file` resource if you need to manually copy package files\n        to the target system.\"","sourceCodeStart":403,"sourceCodeEnd":439,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/type/package.rb#L403-L439","documentation":"The package type's flavor property (OpenBSD flavors, DNF module profiles) validates against `ensure => disabled`: disabling a package while also selecting a flavor is contradictory, so ArgumentError 'Cannot have both `ensure => disabled` and `flavor`' is raised.","triggerScenarios":"`package { 'postgresql': ensure => disabled, flavor => 'minimal' }`; Hiera data merging that sets flavor on a resource whose ensure resolves to disabled; parameterized classes combining both flags through defaults.","commonSituations":"Shared Hiera data applying flavor globally while some nodes disable the package; refactors flipping ensure to disabled without removing flavor; copy-paste combining flavor examples from module docs with disable recipes.","solutions":["Remove `flavor` on resources where ensure => disabled (or change ensure).","Make them mutually exclusive in data: `flavor => $ensure ? { 'disabled' => undef, default => 'default' }`.","Audit layers with `puppet lookup flavor --explain` and `puppet lookup ensure --explain`.","For DNF modules use enable_only instead of flavor when disabling."],"exampleFix":"// before\npackage { 'postgresql':\n  ensure => disabled,\n  flavor => 'minimal',\n}\n\n// after\npackage { 'postgresql':\n  ensure => disabled,\n}","handlingStrategy":"validation","validationCode":"// Puppet\nif $flavor != undef and $ensure == 'disabled' {\n  fail('flavor cannot be combined with ensure => disabled')\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Make flavor conditional on ensure in shared data.","Use puppet lookup --explain for both keys on affected nodes.","Keep disable profiles and flavored installs in separate classes."],"tags":["puppet","package","flavor","mutually-exclusive","openbsd","dnf"],"backgroundTag":"mutually-exclusive-parameters","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}