BUG-7697: add defences against nulls