Shopify/liquid · warning

DEPRECATION WARNING: Condition#evaluate without a context…

Error message

DEPRECATION WARNING: Condition#evaluate without a context argument is deprecated and will be removed from Liquid 6.0.0.

What it means

Calling Condition#evaluate with no context argument is deprecated; the method warns and substitutes a fresh empty Context so old call sites keep working until Liquid 6.0.0, where the argument becomes mandatory. Evaluating a condition without a real context cannot resolve variables, so the shim is only a compatibility aid.

Solutions

  1. Pass the current Context explicitly: cond.evaluate(context)
  2. In custom tags, use the context available in render and drop the zero-arg form before Liquid 6.0.0

Example fix

// before
condition.evaluate
// after
condition.evaluate(context)
Defensive patterns

Strategy: type-guard

Validate before calling

raise ArgumentError, 'context required' unless context.is_a?(Liquid::Context)
condition.evaluate(context)

Type guard

def with_context?(cond) cond.method(:evaluate).arity != 0 end

Prevention

When it happens

Trigger: Invoking cond.evaluate on a Liquid::Condition instance without passing a Context, typically from custom tag code or tests that introspect parsed conditions.

Common situations: Custom tag implementations upgraded from Liquid 4 where evaluate took no context; test suites asserting condition results directly.

Understand the failure class

Background: "is deprecated and will be removed" — deprecation warnings for old API names, keywords, and options, and how to migrate before the removal release — this error's family across 29 libraries.

Related errors


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

Appendix: source

Thrown at lib/liquid/condition.rb:200

      left  = Liquid::Utils.to_liquid_value(context.evaluate(left))
      right = Liquid::Utils.to_liquid_value(context.evaluate(right))

      operation = self.class.operators[op] || raise(Liquid::ArgumentError, "Unknown operator #{op}")

      if operation.respond_to?(:call)
        operation.call(self, left, right)
      elsif left.respond_to?(operation) && right.respond_to?(operation) && !left.is_a?(Hash) && !right.is_a?(Hash)
        begin
          left.send(operation, right)
        rescue ::ArgumentError => e
          raise Liquid::ArgumentError, e.message
        end
      end
    end

    def deprecated_default_context
      warn("DEPRECATION WARNING: Condition#evaluate without a context argument is deprecated " \
        "and will be removed from Liquid 6.0.0.")
      Context.new
    end

    class ParseTreeVisitor < Liquid::ParseTreeVisitor
      def children
        [
          @node.left,
          @node.right,
          @node.child_condition,
          @node.attachment
        ].compact
      end
    end
  end

  class ElseCondition < Condition
    def else?

View on GitHub (pinned to 807d45a6b3)