Skip to content

Fbe.sec crashes with ArgumentError on a Float seconds value #630

Description

@morphqdd

What Happens

lib/fbe/sec.rb:27:

s = Integer(s.first.to_s, 10)

Integer() rejects any string containing a decimal point. If the fact's seconds (or a custom prop) property is a Float, which is exactly what Time.now - start_time produces in plain Ruby, this raises ArgumentError: invalid value for Integer(): "7200.5" instead of formatting the duration.

All four existing tests in test/fbe/test_sec.rb only use Integer literals, so this gap is untested.

Verified:

cd ~/zerocrasy/fbe && nix-shell ~/zerocrasy/shell.nix --run \
  "BUNDLE_GEMFILE=~/zerocrasy/fbe/Gemfile bundle exec ruby -I lib repro_sec_float.rb"

Output: ERROR: ArgumentError: invalid value for Integer(): "7200.5"

What Should Happen

Fbe.sec should accept a Float seconds value without crashing, coercing through Float first, the same pattern already used elsewhere in this codebase (for example pmp.rb's Integer(Float(result).truncate)), e.g. Integer(Float(s.first).round).

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