Shopify/liquid · error · Liquid::ArgumentError

invalid integer

Error message

invalid integer

What it means

TableRow#to_integer calls value.to_i and, if the object does not respond to to_i (NoMethodError), re-raises Liquid::ArgumentError with message 'invalid integer'. It guards the cols/offset/limit attributes of {% tablerow %}, which must be integer-convertible.

Solutions

  1. Ensure the attribute value is an Integer or something responding to to_i (e.g. a numeric String).
  2. Convert drops/objects to numbers in Ruby before assigning them in the template.
  3. Use literal integers in the tag: cols: 3.

Example fix

// before
{% assign cfg = site.layout %}{% tablerow item in items, cols: cfg %}...{% endtablerow %}
// after
{% tablerow item in items, cols: 3 %}...{% endtablerow %}
Defensive patterns

Strategy: type-guard

Validate before calling

raise ArgumentError, 'cols must respond to to_i' unless value.respond_to?(:to_i) || value.is_a?(Integer)

Type guard

def integer_value?(v)
  v.is_a?(Integer) || v.respond_to?(:to_i)
end

Try / catch

begin
  output = template.render(assigns)
rescue Liquid::ArgumentError => e
  raise e if e.message == 'invalid integer'
  raise
end

Prevention

When it happens

Trigger: Passing an object without to_i (e.g. nil in some configurations, a Hash, or a Drop) as the value of cols/offset/limit in {% tablerow %}, resolved during render_to_output_buffer.

Common situations: Assigning a complex object or nil to a variable used for cols; API/drop objects that do not implement to_i; typos where a string with units ('10px') is expected to work but the object lacks to_i.

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


AI-assisted analysis of Shopify/liquid@807d45a6b3 (2026-09-08). Data as JSON: /api/errors/4fb01983492c233a. Report an issue: GitHub.

Appendix: source

Thrown at lib/liquid/tags/table_row.rb:134

        end
      end

      output << "</tr>\n"
      output
    end

    class ParseTreeVisitor < Liquid::ParseTreeVisitor
      def children
        super + @node.attributes.values + [@node.collection_name]
      end
    end

    private

    def to_integer(value)
      value.to_i
    rescue NoMethodError
      raise Liquid::ArgumentError, "invalid integer"
    end
  end
end

View on GitHub (pinned to 807d45a6b3)