ComfyUI Node

_.minBy

The _.minBy That Wants a Callable It Can't Be Given

By sfinktah·Created about a year ago·Updated 10 months ago· 7
_.minBy
  • obj
  • *
key

_.minBy is the node that looks like it'll find you the cheapest LoRA or the lowest seed in a list of metadata objects - and then, more likely than not, dies with TypeError: 'str' object is not callable. It's part of comfy-ovum's underscore family, a port of underscore.js collection methods into graph-friendly nodes. The idea is right; the wiring is where the good intentions run into Python's min().

What it's supposed to do

Standard lodash-style minBy finds the minimum element of a list, where "minimum" is decided by a key: give it a list of dicts and a property name, and it returns the single element with the smallest value for that property. That's genuinely the kind of thing you want when a workflow hands you a list of scored candidates and you need to pick the best one.

The inputs reflect that intent:

  • obj - the list (or _.CHAIN) you're mining for a minimum
  • key - a string widget for the property name

One output: the winning element, as ANY.

Where it falls over

Here's the thing: the node feeds that string key straight into Python's built-in min(list, key=key), and Python's key argument has to be a callable, not a name. A string isn't callable. I tested the shipped code with minBy('name') on a list of dicts and got exactly TypeError: 'str' object is not callable. Even the empty-string default hits it, because key="" is still a string. So the obvious "type the property name" workflow crashes on every run.

There's no predicate socket and no JSON fallback on this one, either - unlike the iteratee-based nodes in the same family, minBy only exposes the widget. So there's no clean way to hand it a working callable through the graph.

What to do instead

Reach for its sibling _.min instead. _.min goes through underscore's iteratee machinery, which does accept shorthand: feed a property name and it turns it into a property accessor for you. If _.min isn't enough, _.sortBy + take the first element is the classic workaround, and _.pluck will happily pull every value of one field out so you can compare them directly.

Installing

This ships inside the comfy-ovum pack (sfinktah's "assorted reliquary of nodes"). Install the pack and you get the whole underscore family at once. ComfyUI Manager → search comfy-ovum → Install, or the manual route:

cd ComfyUI/custom_nodes
git clone https://github.com/sfinktah/comfy-ovum

Restart ComfyUI. No model downloads, and the underscore nodes need zero extra pip packages - the underscore.js port is bundled in the repo. The pack's requirements.txt (pymediainfo, aiohttp, requests and friends) exists for its other nodes, so if Manager auto-installs all of it you may grab a few packages this node will never touch.

The bottom line

If you need min-by-property, use _.min with the property name as its iteratee. _.minBy is the kind of node that ships as a stub and trips over Python's stricter key semantics - good to know it's a trap before you burn ten minutes wondering what you did wrong.

Categoryovum/underscore

Inputs (2)

NameTypeDefaultDescription
objopt*Primary input object. Also accepts _.CHAIN to continue chaining.
keyoptSTRINGkey (string)

Outputs (1)

NameTypeDescription
**