Skip to content

Fbe.kill_if crashes with NoMethodError on nil when a fact lacks the fid property #620

Description

@morphqdd

What happens

Fbe.kill_if (lib/fbe/kill_if.rb:20) collects fact IDs with:

ids << f[fid].first

When a fact does not have the fid property (the property name is a parameter, fid: '_id' is only the default), f[fid] returns nil and the call crashes:

NoMethodError: undefined method 'first' for nil

A caller who passes a custom fid (or feeds facts that predate the _id-assigning Factbase::Pre decorator, e.g. raw facts in tests) gets a bare NoMethodError from deep inside the loop instead of a meaningful failure. Additionally, if f[fid] were ever an empty array, nil would silently land in ids and later render as (eq _id ) in the delete query — a malformed term.

What should happen

kill_if should either skip facts that lack the fid property or raise a clear Fbe::Error naming the fact and the missing property — anything but a raw NoMethodError on nil.

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