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
- Pass the current Context explicitly: cond.evaluate(context)
- 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
- Always pass context explicitly in custom tag render code
- Pin Liquid < 6.0.0 only as a stopgap; fix call sites before upgrading
- Cover Condition usage with tests that run with deprecation warnings visible
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
- Template.error_mode= is deprecated. Use…
- [DEPRECATION] # is deprecated. Use # instead. Called from #…
- :rigid is deprecated. Use :strict2 instead.
- Template.default_exception_renderer=
- Template.file_system=
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)