Shopify/liquid · error · Liquid::ArgumentError
cannot select the property '#
Error message
cannot select the property '#{Utils.to_s(property)}' What it means
`raise_property_error` raises Liquid::ArgumentError with the property name that could not be selected. It is raised by array filters (sort, sort_natural, uniq, map, compact, sum) when the `property` argument cannot be resolved on items — typically when an item does not respond to `[]` for the given key and the inner fetch cannot be completed. Liquid uses this to fail fast with a clear, property-specific message instead of an obscure internal error.
Solutions
- Check each element of the array is a hash/object exposing the property before applying the filter.
- Fix the property name spelling/typo in the filter argument.
- Transform primitives into objects first (e.g. wrap strings in hashes) or map manually with a for loop.
- Rescue Liquid::ArgumentError during rendering and render an alternate template or empty result.
- Validate the shape of data assigned from remote sources before it enters the template context.
Example fix
// before
{{ strings | map: 'name' }}
// after
{% for s in strings %}{{ s }}{% endfor %} Defensive patterns
Strategy: type-guard
Validate before calling
# before render
raise "elements not hash-like" unless array.all? { |i| i.respond_to?(:[]) }
raise "missing property" unless array.all? { |i| i.key?("name") } Type guard
def property_selectable?(arr, prop)
arr.is_a?(Array) && arr.all? { |i| i.respond_to?(:[]) && !i.nil? }
end Try / catch
begin template.render(assigns) rescue Liquid::ArgumentError => e render_unfiltered_array end
Prevention
- Validate array element shapes before passing to map/sort/sum
- Check property-name spelling against the data schema
- Do not map over arrays of primitives; restructure data first
- Add contract tests for remote data feeding array filters
When it happens
Trigger: Calling `{{ array | map: 'name' }}`, `sort: 'key'`, `sum: 'amount'`, etc., where the property argument is invalid or the array contains elements (like plain strings/integers) that cannot be indexed by that property.
Common situations: Mapping over an array of primitives instead of hashes; typos in the property name; schema changes in upstream data (hashes no longer having the expected key type); passing objects where nested access with dot syntax is mistaken for map support.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- e.message (re-raised as Liquid::ArgumentError from…
- cannot sort values of incompatible types
- errors.argument.include
- invalid integer
- Expected Hash or Liquid::Context as parameter
AI-assisted analysis of Shopify/liquid@807d45a6b3 (2026-09-08).
Data as JSON: /api/errors/a0e71791b0a4f2b6.
Report an issue: GitHub.
Appendix: source
Thrown at lib/liquid/standardfilters.rb:1026
return default_value if ary.empty?
block.call(ary) do |item|
if target_value.nil?
item[property]
else
item[property] == target_value
end
rescue TypeError
raise_property_error(property)
rescue NoMethodError
return nil unless item.respond_to?(:[])
raise
end
end
def raise_property_error(property)
raise Liquid::ArgumentError, "cannot select the property '#{Utils.to_s(property)}'"
end
def apply_operation(input, operand, operation)
result = Utils.to_number(input).send(operation, Utils.to_number(operand))
result.is_a?(BigDecimal) ? result.to_f : result
end
def nil_safe_compare(a, b)
result = a <=> b
if result
result
elsif a.nil?
1
elsif b.nil?
-1
else
raise Liquid::ArgumentError, "cannot sort values of incompatible types"View on GitHub (pinned to 807d45a6b3)