forem/forem · error · StandardError

Limit must be between 1 and 50

Error message

Limit must be between 1 and 50

What it means

The limit option for {% org_team %} must parse as an integer and fall in 1..MAX_LIMIT (50). parse_limit uses Integer(value, exception: false), so non-numeric values yield nil; nil, 0, negative numbers, and values above 50 all raise the same range message. The default when omitted is 50.

Source

Thrown at app/liquid_tags/org_team_tag.rb:52

  def parse_options(option_tokens)
    @limit = DEFAULT_LIMIT
    @role = "all"

    option_tokens.each do |token|
      match = token.match(OPTION_REGEXP)
      raise StandardError, I18n.t("liquid_tags.org_team_tag.invalid_option", option: token) unless match

      key, value = match[1], match[2]
      raise StandardError, I18n.t("liquid_tags.org_team_tag.invalid_option", option: key) unless VALID_OPTIONS.include?(key)

      send(:"parse_#{key}", value)
    end
  end

  def parse_limit(value)
    @limit = Integer(value, exception: false)
    unless @limit && @limit >= 1 && @limit <= MAX_LIMIT
      raise StandardError, I18n.t("liquid_tags.org_team_tag.invalid_limit")
    end
  end

  def parse_role(value)
    unless VALID_ROLES.include?(value)
      raise StandardError, I18n.t("liquid_tags.org_team_tag.invalid_role")
    end

    @role = value
  end

  def build_query
    case @role
    when "admins"
      @organization.users.joins(:organization_memberships)
        .where(organization_memberships: { organization_id: @organization.id, type_of_user: "admin" })
    when "members"
      @organization.users.joins(:organization_memberships)

View on GitHub (pinned to f354c376a7)

Solutions

  1. Set limit to an integer between 1 and 50
  2. Note that omitting limit already shows up to 50 members, the maximum
  3. For larger rosters, link to the org's members page instead of raising the limit

Example fix

// before
{% org_team forem limit=200 %}

// after
{% org_team forem limit=50 %}
Defensive patterns

Strategy: validation

Validate before calling

limit = Integer(value, exception: false)
raise ArgumentError, 'limit must be 1..50' unless limit&.between?(1, 50)

Type guard

def valid_org_team_limit?(value)
  limit = Integer(value.to_s, exception: false)
  limit.is_a?(Integer) && limit.between?(1, 50)
end

Try / catch

begin
  Liquid::Template.parse(body_markdown)
rescue StandardError => e
  errors.add(:body_markdown, "Liquid tag error: #{e.message}") # 'Limit must be between 1 and 50'
end

Prevention

When it happens

Trigger: limit=0, limit=51, limit=100, or a non-numeric value such as limit=abc.

Common situations: Large orgs wanting to show everyone; typos; expecting silent clamping instead of an error.

Related errors


AI-assisted analysis of forem/forem@f354c376a7 (2026-08-21). Data as JSON: /api/errors/5adfbdc416f1ee79. Report an issue: GitHub.