Skip to content

Fbe::Conclude#roll crashes with RuntimeError when draw block does not return a String #445

@morphqdd

Description

@morphqdd

conclude.rb:211 calls @loog.info("#{n.what}: #{n.details}") on every fact produced by draw. However, fill sets n.what and n.details only when the block returns a String:

def fill(fact, prev)
  r = yield(fact, prev)
  return unless r.is_a?(String)
  fact.details = r
  fact.what = @judge
end

When the block returns anything else (e.g. nil from $loog.info(...), or an Integer), n.what is never set. Factbase::Fact raises RuntimeError: Can't find 'what' attribute when reading an unset property, causing a crash in roll.

Minimal reproduction:

Fbe.conclude(fb: fb, judge: 'test') do
  quota_unaware
  on '(always)'
  draw do |n, _f|
    n.score = 42
    # returns Integer — fill does NOT set n.what/n.details → crash
  end
end
# => RuntimeError: Can't find 'what' attribute out of [score]

What should happen: roll should not assume n.what and n.details are always set. Either fill should unconditionally set n.what = @judge, or roll should guard the log line against unset attributes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions