spree/spree · warning

Calling Spree::StockReservations::Extend with order: is depr

Error message

Calling Spree::StockReservations::Extend with order: is deprecated and will be removed in Spree 6.1. Pass cart: instead.

What it means

Checkout stock reservations are keyed to the cart after the 6.0 Cart/Order split. Spree::StockReservations::Extend pushes out the expiry of a cart's reservations (returning early with success when the store has stock_reservations_enabled off); passing order: logs this warning and maps onto cart for one release. Removed in 6.1.

Source

Thrown at spree/core/app/services/spree/stock_reservations/extend.rb:8

module Spree
  module StockReservations
    class Extend
      prepend Spree::ServiceModule::Base

      def call(cart: nil, order: nil)
        if order
          Spree::Deprecation.warn('Calling Spree::StockReservations::Extend with order: is deprecated and will be removed in Spree 6.1. Pass cart: instead.')
          cart ||= order
        end
        return success(cart) unless Spree::StorePreferences.read(cart&.store, :stock_reservations_enabled)

        expires_at = Time.current + Spree::StockReservation.ttl_for(cart)

        Spree::StockReservation
          .merge(Spree::StockReservation.for_order(cart))
          .update_all(expires_at: expires_at, updated_at: Time.current)

        success(cart)
      end
    end
  end
end

View on GitHub (pinned to 06bf66a868)

Solutions

  1. Rename the keyword: Spree::StockReservations::Extend.call(cart: cart).
  2. Migrate the Reserve twin (error 237) in the same sweep — both share the exact bridge shape.
  3. Keep relying on Spree::StockReservation.ttl_for(cart) if you compute your own expiry windows.
  4. Verify with deprecations raised that no call site remains.

Example fix

# before
Spree::StockReservations::Extend.call(order: order)

# after
Spree::StockReservations::Extend.call(cart: cart)
Defensive patterns

Strategy: validation

Validate before calling

kwargs =
  if Spree::StockReservations::Extend.instance_method(:call).parameters.any? { |_, name| name == :cart }
    { cart: cart }
  else
    { order: cart }
  end
Spree::StockReservations::Extend.call(**kwargs)

Type guard

# @return [Boolean] true when Extend accepts cart:
def spree_reservations_extend_cart_kwarg?
  Spree::StockReservations::Extend.instance_method(:call).parameters.any? { |_, name| name == :cart }
end

Prevention

When it happens

Trigger: Spree::StockReservations::Extend.call(order: order) — checkout-step extensions or jobs that keep reservations alive while the shopper proceeds, written before the split.

Common situations: Apps with stock reservations enabled upgrading to 6.0; custom checkout timers/heartbeat code; specs extending reservations during long checkouts.

Related errors


AI-assisted analysis of spree/spree@06bf66a868 (2026-08-21). Data as JSON: /api/errors/c58c2c9b35fd08d3. Report an issue: GitHub.