{"record":{"id":"a0e71791b0a4f2b6","repo":"Shopify/liquid","slug":"cannot-select-the-property-utils-to-s-property","errorCode":null,"errorMessage":"cannot select the property '#{Utils.to_s(property)}'","messagePattern":"cannot select the property '#(.+?)'","errorType":"exception","errorClass":"Liquid::ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/liquid/standardfilters.rb","lineNumber":1026,"sourceCode":"\n      return default_value if ary.empty?\n\n      block.call(ary) do |item|\n        if target_value.nil?\n          item[property]\n        else\n          item[property] == target_value\n        end\n      rescue TypeError\n        raise_property_error(property)\n      rescue NoMethodError\n        return nil unless item.respond_to?(:[])\n        raise\n      end\n    end\n\n    def raise_property_error(property)\n      raise Liquid::ArgumentError, \"cannot select the property '#{Utils.to_s(property)}'\"\n    end\n\n    def apply_operation(input, operand, operation)\n      result = Utils.to_number(input).send(operation, Utils.to_number(operand))\n      result.is_a?(BigDecimal) ? result.to_f : result\n    end\n\n    def nil_safe_compare(a, b)\n      result = a <=> b\n\n      if result\n        result\n      elsif a.nil?\n        1\n      elsif b.nil?\n        -1\n      else\n        raise Liquid::ArgumentError, \"cannot sort values of incompatible types\"","sourceCodeStart":1008,"sourceCodeEnd":1044,"githubUrl":"https://github.com/Shopify/liquid/blob/807d45a6b3d4568e64e86b375e3702df2c7c860c/lib/liquid/standardfilters.rb#L1008-L1044","documentation":"`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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\n{{ strings | map: 'name' }}\n// after\n{% for s in strings %}{{ s }}{% endfor %}","handlingStrategy":"type-guard","validationCode":"# before render\nraise \"elements not hash-like\" unless array.all? { |i| i.respond_to?(:[]) }\nraise \"missing property\" unless array.all? { |i| i.key?(\"name\") }","typeGuard":"def property_selectable?(arr, prop)\n  arr.is_a?(Array) && arr.all? { |i| i.respond_to?(:[]) && !i.nil? }\nend","tryCatchPattern":"begin\n  template.render(assigns)\nrescue Liquid::ArgumentError => e\n  render_unfiltered_array\nend","preventionTips":["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"],"tags":["liquid","argument-error","property-access","array-filter"],"backgroundTag":"invalid-argument-value","analyzedSha":"807d45a6b3d4568e64e86b375e3702df2c7c860c","analyzedAt":"2026-09-08T11:31:38.917Z","contentChangedAt":"2026-09-08T11:31:38.917Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}