puppetlabs/puppet · error · ArgumentError
Timespans are only comparable to Timespans, Integers, and…
Error message
Timespans are only comparable to Timespans, Integers, and Floats
What it means
CompareOperator#cmp_Timespan guard: a Time::Timespan can only be ordered against another Timespan, Integer, or Float; any other operand type raises.
Solutions
- Convert the operand to a Timespan or numeric value before comparing
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at lib/puppet/pops/evaluator/compare_operator.rb:105 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/3895bb02075daaa1.
Report an issue: GitHub.
Appendix: source
Thrown at lib/puppet/pops/evaluator/compare_operator.rb:105
end
def equals_Hash(a, b)
return false unless b.is_a?(Hash) && a.size == b.size
a.each { |ak, av| return false unless equals(b[ak], av) }
true
end
def cmp_Symbol(a, b)
if b.is_a?(Symbol)
a <=> b
else
raise ArgumentError, _("Symbol not comparable to non Symbol")
end
end
def cmp_Timespan(a, b)
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')View on GitHub (pinned to e227c27540)