puppetlabs/puppet · error · ArgumentError

Only Strings, Numbers, Timespans, Timestamps, and Versions…

Error message

Only Strings, Numbers, Timespans, Timestamps, and Versions are comparable

What it means

Fallback cmp_Object: the spaceship operator was used on operand types (outside String, Numeric, Symbol, Timespan, Timestamp, Version) for which the Puppet language defines no ordering.

Solutions

  1. Convert operands to one of the comparable types (String, Numeric, Timestamp, Timespan, Version) before comparing
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at lib/puppet/pops/evaluator/compare_operator.rb:123 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of puppetlabs/puppet@e227c27540 (2026-08-21). Data as JSON: /api/errors/0f278921d79c8d53. Report an issue: GitHub.

Appendix: source

Thrown at lib/puppet/pops/evaluator/compare_operator.rb:123

    raise ArgumentError, _('Timespans are only comparable to Timespans, Integers, and Floats') unless b.is_a?(Time::Timespan) || b.is_a?(Integer) || b.is_a?(Float)

    a <=> b
  end

  def cmp_Timestamp(a, b)
    raise ArgumentError, _('Timestamps are only comparable to Timestamps, Integers, and Floats') unless b.is_a?(Time::Timestamp) || b.is_a?(Integer) || b.is_a?(Float)

    a <=> b
  end

  def cmp_Version(a, b)
    raise ArgumentError, _('Versions not comparable to non Versions') unless b.is_a?(SemanticPuppet::Version)

    a <=> b
  end

  def cmp_Object(a, b)
    raise ArgumentError, _('Only Strings, Numbers, Timespans, Timestamps, and Versions are comparable')
  end

  def equals_Object(a, b)
    a == b
  end

  def equals_NilClass(a, b)
    # :undef supported in case it is passed from a 3x data structure
    b.nil? || b == :undef
  end

  def equals_Symbol(a, b)
    # :undef supported in case it is passed from a 3x data structure
    a == b || a == :undef && b.nil?
  end

  def include_Object(a, b, scope)
    false

View on GitHub (pinned to e227c27540)