Repository navigation
Description
A route(...) forks over the list its source step returns. When the source body returns something that is not a list, _route_fork returns None (_runner.py:2671-2672), called from the body path at _runner.py:1602-1607. The finalize only attaches a route fork when that value is not None (_runner.py:2250-2254), so the source finalizes succeeded with no fork. No <source>.join row is created, and the consumer that was created waiting on that join keeps deps_pending=1. The _route_fork docstring keeps None for a non-list on purpose. The same paragraph describes this exact state as the wedge the empty-list fix removed: the join row never existed and the consumers' reserved deps were never released (_runner.py:2643-2653).
The build only checks the annotation, get_origin(returned) is list (_graph.py:1679), and encode_result wraps whatever the body returned, with None staying None (_runner_codec.py:190-197). The guide says a non-list source is refused at build (workflows.md:1441-1449), and that refusal looks at the declaration only; the returned value is never checked. A body declared -> list[Image | Audio] that misses a return on one branch, or returns one element without the brackets, passes the build. The map sibling turns a non-list into an empty item list (_runner.py:2483-2485), so its join fires with zero children and the run ends.
Reproduced on ffcb61f against a real Postgres. The source tree there is identical to main at 9b9fa72; nothing under src/ changed in between. The shape:
class Image(BaseModel):
doc_id: str
class Audio(BaseModel):
doc_id: str
class Done(BaseModel):
doc_id: str
async def media(ctx: StepContext) -> list[Image | Audio]:
return None # e.g. a branch that forgot its return
async def on_image(ctx: StepContext, item: Image) -> Done:
return Done(doc_id=item.doc_id)
async def on_audio(ctx: StepContext, item: Audio) -> Done:
return Done(doc_id=item.doc_id)
async def summarize(ctx: StepContext, items: list[Done]) -> dict[str, int]:
return {"n": len(items)}
@app.workflow("route_non_list")
def route_non_list() -> Promise[object]:
routed = route(
step(media, key="media"),
{Image: RouteArm(body=on_image), Audio: RouteArm(body=on_audio)},
)
return build(step(summarize, routed, key="summary"))With media returning None, and again with it returning a bare Image(doc_id="a"), FlowRunner.drive hit its tick limit and returned "max_ticks". Both cases left the same rows: __flow__ running, media succeeded, summary pending with deps_pending=1. The flow has no media.join row and no edge rows, and no row is failed or carries an error. Fifty more ticks, which run the sweeps and the outbox drain, changed nothing. On the same graph, a source returning [Image, Audio] and one returning [] both end succeeded. A map_source whose source returns None reaches a terminal state with no rows left pending.
The run stays running for good with no failed row and no error class. Nothing alerts, and an operator sees a flow whose only finished step succeeded. The trigger needs a body that breaks its own declared return type, which a type checker would flag in a body like the one above. When such a body does reach the runner, the run should end with a named failure.
PR 750 and PR 751 both change this part of the runner (the fork source in _finalize_success and the route fork's join wiring). The non-list guard is unchanged on both.
Probably wants: _route_fork raising for a non-list return so the body path fails the source with the error on the record, as it already does for an element with no arm via RouterNotTotal (_runner.py:1608-1634). If None should keep meaning "route over nothing" as the docstring says, it needs the empty-list fork. Coercing every non-list to [] the way _map_fork does would end the run, but it would silently drop the element when a body returns a single model.
Activity
XBeg9 commentedon Nov 24, 2026
This one shipped with the route feature itself. The
return Nonefor a non-list return in_route_fork(_runner.py:1732-1733) and the annotation-onlylist[...]check in the build (_graph.py:1042) both blame to5b383f295, the squash of PR 681 that addedtaskq.workflows, and searching the history for that guard turns up no other commit touching it since. I ran the reproduction at that commit and it hangs the same way it does on main: theNoneand bare-model cases both hit the tick limit with__flow__running andsummarypending atdeps_pending=1, and the map control passes. At its parenttaskq.workflowsdoesn't exist yet, so there was never a working version of this path to regress from. The docstring from that same PR already calls the empty-list version of this wedge fixed, so[]got the born-zero join and a non-list return kept theNone.Related:
_route_forkand_map_forkfor a leftover join row, and leaves the non-list guard alone._finalize_successright next to theprebuilt_route_fork is not Nonecheck that lets this source finish with no fork.fix(workflows): harden route refusal wiring, isolation, chain parity,…
fix(workflows): harden route refusal wiring, isolation, chain parity,…
fix(workflows): typed route source returning non-list fails determini…