Skip to content

Iterate#sort_by crashes when matching facts have different value types #1344

Description

@gemshrine

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:

  1. Add matching facts whose rank property contains values of different types, such as integer 2 and string "alpha".
  2. Configure Fbe::Iterate with sort_by('rank') and a query matching both facts.
  3. 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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions