Add some sanity checks to BuildStep.__init__.

Fixes #2271.