{"record":{"id":"2f86b7146dcb57b6","repo":"Shopify/liquid","slug":"deprecation-warning-condition-evaluate-without-a","errorCode":null,"errorMessage":"DEPRECATION WARNING: Condition#evaluate without a context argument is deprecated and will be removed from Liquid 6.0.0.","messagePattern":"DEPRECATION WARNING: Condition#evaluate without a context argument is deprecated and will be removed from Liquid 6\\.0\\.0\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"lib/liquid/condition.rb","lineNumber":200,"sourceCode":"\n      left  = Liquid::Utils.to_liquid_value(context.evaluate(left))\n      right = Liquid::Utils.to_liquid_value(context.evaluate(right))\n\n      operation = self.class.operators[op] || raise(Liquid::ArgumentError, \"Unknown operator #{op}\")\n\n      if operation.respond_to?(:call)\n        operation.call(self, left, right)\n      elsif left.respond_to?(operation) && right.respond_to?(operation) && !left.is_a?(Hash) && !right.is_a?(Hash)\n        begin\n          left.send(operation, right)\n        rescue ::ArgumentError => e\n          raise Liquid::ArgumentError, e.message\n        end\n      end\n    end\n\n    def deprecated_default_context\n      warn(\"DEPRECATION WARNING: Condition#evaluate without a context argument is deprecated \" \\\n        \"and will be removed from Liquid 6.0.0.\")\n      Context.new\n    end\n\n    class ParseTreeVisitor < Liquid::ParseTreeVisitor\n      def children\n        [\n          @node.left,\n          @node.right,\n          @node.child_condition,\n          @node.attachment\n        ].compact\n      end\n    end\n  end\n\n  class ElseCondition < Condition\n    def else?","sourceCodeStart":182,"sourceCodeEnd":218,"githubUrl":"https://github.com/Shopify/liquid/blob/807d45a6b3d4568e64e86b375e3702df2c7c860c/lib/liquid/condition.rb#L182-L218","documentation":"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.","triggerScenarios":"Invoking cond.evaluate on a Liquid::Condition instance without passing a Context, typically from custom tag code or tests that introspect parsed conditions.","commonSituations":"Custom tag implementations upgraded from Liquid 4 where evaluate took no context; test suites asserting condition results directly.","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"],"exampleFix":"// before\ncondition.evaluate\n// after\ncondition.evaluate(context)","handlingStrategy":"type-guard","validationCode":"raise ArgumentError, 'context required' unless context.is_a?(Liquid::Context)\ncondition.evaluate(context)","typeGuard":"def with_context?(cond) cond.method(:evaluate).arity != 0 end","tryCatchPattern":null,"preventionTips":["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"],"tags":["ruby","liquid","deprecation"],"backgroundTag":"deprecated-api-usage","analyzedSha":"807d45a6b3d4568e64e86b375e3702df2c7c860c","analyzedAt":"2026-09-08T11:31:38.917Z","contentChangedAt":"2026-09-08T11:31:38.917Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}