null reference handling in HandlePrimaryAction.