Shopify/liquid · warning

Template.error_mode= is deprecated. Use…

Error message

Template.error_mode= is deprecated. Use Environment#error_mode= instead.

What it means

Assigning Liquid::Template.error_mode= goes through Liquid's deprecation shim, which forwards to Environment#error_mode= and emits a deprecation warning. Template-level global setters were replaced by the Liquid::Environment API, and this path will be removed in a future major version.

Solutions

  1. Replace with Liquid::Environment.default.error_mode = mode or set error_mode on a dedicated Environment instance passed to Template.parse
  2. Silence via Liquid::Deprecations if temporarily unavoidable, but plan the migration

Example fix

// before
Liquid::Template.error_mode = :strict
// after
Liquid::Environment.default.error_mode = :strict
Defensive patterns

Strategy: validation

Validate before calling

warn 'Template.error_mode= is deprecated' if Liquid::Template.respond_to?(:error_mode=) && deprecated_call_site

Prevention

When it happens

Trigger: Calling Liquid::Template.error_mode = :strict (or :lax/:warn/:strict2) anywhere in app code or test setup.

Common situations: Upgrading Liquid from 4.x/5.x to 5.5+ where template-level globals were deprecated; old initializers setting parse strictness on Template instead of Environment.

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/419aab307ca51d16. Report an issue: GitHub.

Appendix: source

Thrown at lib/liquid/template.rb:30

  # Example:
  #
  #   template = Liquid::Template.parse(source)
  #   template.render('user_name' => 'bob')
  #
  class Template
    attr_accessor :root, :name
    attr_reader :resource_limits, :warnings

    attr_reader :profiler

    class << self
      # Sets how strict the parser should be.
      # :lax acts like liquid 2.5 and silently ignores malformed tags in most cases.
      # :warn is the default and will give deprecation warnings when invalid syntax is used.
      # :strict enforces correct syntax for most tags
      # :strict2 enforces correct syntax for all tags
      def error_mode=(mode)
        Deprecations.warn("Template.error_mode=", "Environment#error_mode=")
        Environment.default.error_mode = mode
      end

      def error_mode
        Environment.default.error_mode
      end

      def default_exception_renderer=(renderer)
        Deprecations.warn("Template.default_exception_renderer=", "Environment#exception_renderer=")
        Environment.default.exception_renderer = renderer
      end

      def default_exception_renderer
        Environment.default.exception_renderer
      end

      def file_system=(file_system)
        Deprecations.warn("Template.file_system=", "Environment#file_system=")

View on GitHub (pinned to 807d45a6b3)