puppetlabs/puppet · error · ArgumentError
A String is not comparable to a non String
Error message
A String is not comparable to a non String
What it means
Type dispatch guard in CompareOperator#cmp_String: a Puppet String was compared with the spaceship operator against an operand that is not a String, for which there is no ordering defined.
Solutions
- Convert both operands to Strings before comparing
- Use equality instead of ordering comparison when types differ
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at lib/puppet/pops/evaluator/compare_operator.rb:53 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/350fc83bb3a07521.
Report an issue: GitHub.
Appendix: source
Thrown at lib/puppet/pops/evaluator/compare_operator.rb:53
@@compare_visitor.visit_this_1(self, a, b)
end
# Performs a match of a and b, and returns true if b matches a
def match(a, b, scope = nil)
@@match_visitor.visit_this_2(self, b, a, scope)
end
# Answers is b included in a
def include?(a, b, scope)
@@include_visitor.visit_this_2(self, a, b, scope)
end
protected
def cmp_String(a, b)
return a.casecmp(b) if b.is_a?(String)
raise ArgumentError, _("A String is not comparable to a non String")
end
# Equality is case independent.
def equals_String(a, b)
return false unless b.is_a?(String)
a.casecmp(b) == 0
end
def cmp_Numeric(a, b)
case b
when Numeric
a <=> b
when Time::Timespan, Time::Timestamp
-(b <=> a) # compare other way and invert result
else
raise ArgumentError, _("A Numeric is not comparable to non Numeric")
endView on GitHub (pinned to e227c27540)