ianpaschalI
Convex Community10mo ago
8 replies
ianpaschal

Help understanding 'Validator error: Expected ID for table...'

If you query a document with by an ID, if the ID exists on the table, you get the document back. If it doesn't, you get
null
.

However when testing, when I want to test that my function returns null (or throws a specific error) if the ID in the args is invalid, I instead get the error 'Validator error: Expected ID for table...'

What is the purpose of this error? And why does it behave differently? Shouldn't passing 'not_a_valid_foo_id' for an arg fooId with type v.id('foos')and then calling ctx.db.get(fooId) just return
null
and I can handle that as I like? Why does it throw an error?

Thanks in advance!
Was this page helpful?