@FaheemMitha I don't know how many different ways you need for doing this. You ask "if I was doing something obviously wrong", but I can't find what it is you're having issues with.
@Kusalananda If we are talking about the same thing, the link I posted shows an error message. That's the error message I was asking about. The concensus on TeX SE seems to be that it's just Lua being Lua, not a bug.
And the link is a gist. I haven't posted it anywhere on SE yet, though it seems that SO is probably where it belongs. Since client-side issues with DBs are deemed to be off-topic on DBA SE.
@FaheemMitha Someone who knows Lua will at least be able to point you in the right direction. There are presumably more such peaplo over at SO than here.