{"record":{"id":"82bd1bca2cb214ad","repo":"puppetlabs/puppet","slug":"supported-values-for-property-array-matching-are","errorCode":null,"errorMessage":"Supported values for Property#array_matching are 'first' and 'all'","messagePattern":"Supported values for Property#array_matching are 'first' and 'all'","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/puppet/property.rb","lineNumber":101,"sourceCode":"    #\n    # @note The semantics of these modes are implemented by the method {#insync?}. That method is the default\n    #   implementation and it has a backwards compatible behavior that imposes additional constraints\n    #   on what constitutes a positive match. A derived property may override that method.\n    # @return [Symbol] (:first) the mode in which matching is performed\n    # @see #insync?\n    # @dsl type\n    # @api public\n    #\n    def array_matching\n      @array_matching ||= :first\n    end\n\n    # @comment This is documented as an attribute - see the {array_matching} method.\n    #\n    def array_matching=(value)\n      value = value.intern if value.is_a?(String)\n      # TRANSLATORS 'Property#array_matching', 'first', and 'all' should not be translated\n      raise ArgumentError, _(\"Supported values for Property#array_matching are 'first' and 'all'\") unless [:first, :all].include?(value)\n\n      @array_matching = value\n    end\n\n    # Used to mark a type property as having or lacking idempotency (on purpose\n    # generally). This is used to avoid marking the property as a\n    # corrective_change when there is known idempotency issues with the property\n    # rendering a corrective_change flag as useless.\n    # @return [Boolean] true if the property is marked as idempotent\n    def idempotent\n      @idempotent.nil? ? @idempotent = true : @idempotent\n    end\n\n    # Attribute setter for the idempotent attribute.\n    # @param [bool] value boolean indicating if the property is idempotent.\n    # @see idempotent\n    def idempotent=(value)\n      @idempotent = value","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/property.rb#L83-L119","documentation":"array_matching is a DSL attribute on custom type properties. It controls how an array should-value is compared: :first (default) matches on the first element, :all requires all elements to be present. The setter interns strings to symbols and rejects anything outside [:first, :all] with ArgumentError at type-definition time - that is, as soon as Puppet loads the type, not when a resource is applied.","triggerScenarios":"In a custom type: newproperty(:foo, :array_matching => :any) do ... end, or array_matching 'fist' (typo), or passing nil / a value that cannot be interned.","commonSituations":"Custom type authors guessing the vocabulary (:any, :match_all, :all_matching); values copied from other frameworks' APIs; near-miss strings that get interned and then fail the whitelist check.","solutions":["Use :first (or omit it - it is the default) or :all, as a symbol or exact string.","If neither semantic fits, leave array_matching unset and override insync? in the property to implement custom matching."],"exampleFix":"# before (custom type)\nnewproperty(:members, :array_matching => :any) { ... }   # ArgumentError when the type loads\n\n# after\nnewproperty(:members, :array_matching => :all) { ... }","handlingStrategy":"validation","validationCode":"value = :all\nraise ArgumentError, 'bad array_matching' unless [:first, :all].include?(value)\nnewproperty(:members, :array_matching => value) { ... }","typeGuard":"def valid_array_matching?(v)\n  v = v.to_sym if v.is_a?(String)\n  [:first, :all].include?(v)\nend","tryCatchPattern":null,"preventionTips":["The vocabulary is exactly :first and :all - nothing else.","Test that a custom type loads (puppet parser validate or a spec invoking Puppet::Type.type) before shipping.","Prefer symbols over strings for DSL attributes; strings must be exact after interning."],"tags":["puppet","custom-type","type-dsl","validation"],"backgroundTag":"invalid-enum-value","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}