zed icon indicating copy to clipboard operation
zed copied to clipboard

unify missing semantics for function calls

Open mccanne opened this issue 3 years ago • 0 comments

Repro is with Zed commit 9c0f097.

Most functions don't handle missing properly.

In general, a function should return missing if any required argument is missing, e.g.,

$ zed -version
Version: v1.2.0-49-g9c0f0973

$ zed log -z
{Name:"main",Commit:0x0fafd0fa5c040fcdfd51485e0ec7f7d99af5f5ab(=ksuid.KSUID)}(=lake.BranchTip)
{id:0x0fafd0fa5c040fcdfd51485e0ec7f7d99af5f5ab(=KSUID),parent:0x0000000000000000000000000000000000000000(KSUID),retries:0(uint8),author:"[email protected]",date:2022-09-14T18:35:38.207529Z,message:"loaded 1 data object\n\n  2ElqV0SHaPKU1YDHoFyrEOImPhb 35493 records in 1663930 data bytes\n",meta:null}(=Commit)

$ zed log -z | zq -z 'yield ksuid(id)' -
error("ksuid: argument must a bytes or string type (bad argument: error(\"missing\"))")
"2ElqV2ggRY24fBQo26yJZLX4nUJ"

So the error comes from processing the branch-tip record (which has no id) instead of just skipping it.

We should audit all the functions and make sure each has proper missing semantics.

mccanne avatar Mar 25 '22 16:03 mccanne