move the sanity checks from #540 to the query builder instead. @dantleech do we have the document metadata available in the query builder?