spree/spree · warning

#name is deprecated and will be removed in Spree 6.1. Use #l

Error message

#name is deprecated and will be removed in Spree 6.1. Use #label instead.

What it means

Spree 6.0 renamed the Metafields system to Custom Fields, and the definition's name column became label. Spree::CustomFieldDefinition#name is now a deprecation shell: it emits this warning via Spree::Deprecation.warn and forwards to label (the writer name= forwards to label=). Both shells are deleted in Spree 6.1, after which the call fails.

Source

Thrown at spree/core/app/models/spree/custom_field_definition.rb:83

      # have no token. Anything else gets surfaced as an error on `field_type`
      # so API clients get a token-vocabulary message instead of a raw
      # class-name inclusion error.
      @field_type_input_recognized = !mapped.nil? || valid_available_types.include?(string_value)
      super(mapped || value)
    end

    # The raw STI class name stored in the column, as opposed to the API token
    # returned by {#field_type}.
    # @return [String]
    def field_type_class_name
      self[:field_type]
    end

    #
    # Deprecated 6.0 column names, removed in 6.1
    #
    def name
      Spree::Deprecation.warn('#name is deprecated and will be removed in Spree 6.1. Use #label instead.')
      label
    end

    def name=(value)
      Spree::Deprecation.warn('#name= is deprecated and will be removed in Spree 6.1. Use #label= instead.')
      self.label = value
    end

    def metafield_type
      Spree::Deprecation.warn('#metafield_type is deprecated and will be removed in Spree 6.1. Use #field_type (which returns an API token) or #field_type_class_name instead.')
      field_type_class_name
    end

    def metafield_type=(value)
      Spree::Deprecation.warn('#metafield_type= is deprecated and will be removed in Spree 6.1. Use #field_type= instead.')
      self.field_type = value
    end

View on GitHub (pinned to 06bf66a868)

Solutions

  1. Rename all reads to definition.label and all writes to definition.label=.
  2. Grep for the sibling shells on the same model: .metafield_type and .metafield_type= — they are deprecated in the same block and removed together.
  3. Run the suite with Spree::Deprecation.behavior = :raise so remaining call sites fail loudly instead of only logging.
  4. Before upgrading to Spree 6.1, update or drop third-party gems that still call the pre-6.0 Metafields API.

Example fix

# before
definition.name = 'Size'

# after
definition.label = 'Size'
Defensive patterns

Strategy: validation

Validate before calling

# spec/spec_helper.rb — turn any deprecated Spree call into a failing spec
Spree::Deprecation.behavior = :raise

Type guard

# Cross-version helper: prefer the 6.0 name when present
definition.respond_to?(:label) ? definition.label : definition.name

Prevention

When it happens

Trigger: Calling definition.name or definition.name = 'Size' on a Spree::CustomFieldDefinition — extension code, custom dashboards, rake tasks, imports or serializers written against the pre-6.0 Metafields API that display or search definitions by name.

Common situations: Upgrading a Spree 5.x app or extension that managed metafield definitions; CSV export/report code still keyed on .name; copy-pasted metafields samples. Usually shows up as repeated log noise during test runs after bumping to Spree 6.0.

Related errors


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