I noticed when spilling to disk in $lookup plans that use HashAgg we can get into a situation where we only have a single row in the HashAgg stage with an empty group by key. If this spills we can trip an invariant in the server.
I fixed this when merging spilling in HashLookupStage and added a C++ for this exact scenario in the HashAgg unittests.
We should use this ticket to backport the fix applied in SERVER-62739 which is to check the _inKeyAccessor.size() == 0 and bail out of spilling.
This is okay because we will only have a single row in the hash table and there's no point in spilling to disk because we will have spill and re-load the value into memory when updating it via point the switch accessor to the value and running the bytecode.