remove redundant code and better error msg Upstream-commit: 9a6ebf08e75c35a2041a18bcc6e0883021dc65b5 Component: engine