danbooru/danbooru · error · PostQuery::TagLimitError

You cannot search for more than #{CurrentUser.tag_query_limi

Error message

You cannot search for more than #{CurrentUser.tag_query_limit} tags at a time.

What it means

Error "You cannot search for more than #{CurrentUser.tag_query_limit} tags at a time." thrown in danbooru/danbooru.

Source

Thrown at app/logical/post_query.rb:321

    def exact_count(timeout)
      Post.with_timeout(timeout) do
        posts.count
      end
    end

    def count_cache_key
      if is_user_dependent_search?
        "post-count-for-user:#{current_user.id.to_i}:#{to_s}"
      else
        "post-count:#{to_s}"
      end
    end
  end

  concerning :ValidationMethods do
    def validate_tag_limit!
      return if is_empty_search? || is_simple_tag?
      raise TagLimitError if tag_limit.present? && term_count > tag_limit
    end

    def validate_metatags!
      return if is_empty_search? || is_simple_tag?
      return if metatags.empty?

      order_metatags = select_metatags(*ORDER_METATAGS).map(&:to_s).map(&:downcase).uniq
      raise Error, "#{order_metatags.to_sentence} can't be used together." if order_metatags.size > 1

      SINGLETON_METATAGS.each do |name|
        metatag = select_metatags(name).first
        raise Error, "'#{name}:' can't be used more than once." if select_metatags(name).map(&:to_s).map(&:downcase).uniq.size > 1
        raise Error, "'#{metatag}' can't be negated." if metatag&.parents&.any?(&:not?)
        raise Error, "'#{metatag}' can't be used with the 'or' operator." if metatag&.parents&.any?(&:or?)
      end
    end

    # The number of unique tags, wildcards, and metatags in the search, excluding metatags that don't count against the user's tag limit.

View on GitHub (pinned to 91fec09564)

Solutions

  1. Reduce the number of tags in the search to at most the limit shown in the message.
  2. Split the search into multiple smaller searches.
  3. Upgrade the account to raise the tag query limit, if applicable.

When it happens

Trigger: Thrown at app/logical/post_query.rb:321 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of danbooru/danbooru@91fec09564 (2026-08-24). Data as JSON: /api/errors/e94b865798f8707d. Report an issue: GitHub.