puppetlabs/puppet · error · Puppet::DataBinding::LookupError

Data Provider type mismatch: Got

Error message

Data Provider type mismatch: Got %{klass} when a hash-like object was expected to access value using '%{segment}' from key '%{key}'

What it means

SubLookup tried to descend a lookup key segment into a value that is neither a Hash nor an Array-with-integer-segment: the data structure does not have the hash-like shape the dotted key requires.

Solutions

  1. Fix the data so intermediate values along the key path are hashes (or arrays indexed numerically)
  2. Adjust the lookup key to match the actual data shape
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at lib/puppet/pops/lookup/sub_lookup.rb:78 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of puppetlabs/puppet@e227c27540 (2026-08-21). Data as JSON: /api/errors/7a269b7b21d4af56. Report an issue: GitHub.

Appendix: source

Thrown at lib/puppet/pops/lookup/sub_lookup.rb:78

  #
  # @api public
  def sub_lookup(key, context, segments, value)
    lookup_invocation = context.is_a?(Invocation) ? context : context.invocation
    lookup_invocation.with(:sub_lookup, segments) do
      segments.each do |segment|
        lookup_invocation.with(:segment, segment) do
          if value.nil?
            lookup_invocation.report_not_found(segment)
            throw :no_such_key
          end
          if segment.is_a?(Integer) && value.instance_of?(Array)
            unless segment >= 0 && segment < value.size
              lookup_invocation.report_not_found(segment)
              throw :no_such_key
            end
          else
            unless value.respond_to?(:'[]') && !(value.is_a?(Array) || value.instance_of?(String))
              raise Puppet::DataBinding::LookupError,
                    _("Data Provider type mismatch: Got %{klass} when a hash-like object was expected to access value using '%{segment}' from key '%{key}'") %
                    { klass: value.class.name, segment: segment, key: key }
            end
            unless value.include?(segment)
              lookup_invocation.report_not_found(segment)
              throw :no_such_key
            end
          end
          value = value[segment]
          lookup_invocation.report_found(segment, value)
        end
      end
      value
    end
  end
end
end
end

View on GitHub (pinned to e227c27540)