Fbe::Iterate#sort_by crashes when matching facts use different valid value types for the selected property. Factbase permits a property to contain values such as both integers and strings, but the iterator collects those values and calls Ruby's Array#sort! without a mixed-type comparison strategy.
Steps to reproduce:
- Add matching facts whose
rank property contains values of different types, such as integer 2 and string "alpha".
- Configure
Fbe::Iterate with sort_by('rank') and a query matching both facts.
- Run the iteration.
Actual result: the first call to values[repo].next builds the list with .filter_map { _1[@sorting]&.first }.uniq.sort!.each. Ruby cannot compare an Integer with a String, so sorting raises ArgumentError and the repository scan aborts before the block processes its results.
Expected result: a mixed-type property should not crash the iterator. It should either use a documented deterministic ordering for valid Factbase values or reject the heterogeneous values with an actionable validation error before iteration begins.
Technical evidence: lib/fbe/iterate.rb implements sort_by by sorting raw property values in Ruby. Factbase allows strings, integers, floats, times, and booleans as valid property values, and a property can hold multiple values. The sort_by API currently has no requirement that all selected values share one type.
Fbe::Iterate#sort_bycrashes when matching facts use different valid value types for the selected property. Factbase permits a property to contain values such as both integers and strings, but the iterator collects those values and calls Ruby'sArray#sort!without a mixed-type comparison strategy.Steps to reproduce:
rankproperty contains values of different types, such as integer2and string"alpha".Fbe::Iteratewithsort_by('rank')and a query matching both facts.Actual result: the first call to
values[repo].nextbuilds the list with.filter_map { _1[@sorting]&.first }.uniq.sort!.each. Ruby cannot compare anIntegerwith aString, so sorting raisesArgumentErrorand the repository scan aborts before the block processes its results.Expected result: a mixed-type property should not crash the iterator. It should either use a documented deterministic ordering for valid Factbase values or reject the heterogeneous values with an actionable validation error before iteration begins.
Technical evidence:
lib/fbe/iterate.rbimplementssort_byby sorting raw property values in Ruby. Factbase allows strings, integers, floats, times, and booleans as valid property values, and a property can hold multiple values. Thesort_byAPI currently has no requirement that all selected values share one type.