This a nice catch. We had another bug in that area: a function was called and the return value was discarded. That was a mistake and I made it use the result, but it turns out that the function is buggy and it does not handle empty results. It was originally introduced in:
and then nudged in:
I fixed it in and will be available to update after review: