I think this is happening because your database table vw_route is missing a UNIQUE index 'itemid' on columns itemtypeid+itemid, which I see is possible if you once upgraded from earlier than 4.0.7, and it would make it possible to generate duplicate vw_route records in some situations like accidentally double-clicking the submit button to create a new page. When we do a reverse lookup in the 4.0.21 upgrade step and then the forward lookup, the records do not match, and some of the fields are missing as a result.
This error message is a minor E_NOTICE so you should be able to complete the upgrade if you disable XenForo's debug mode while you upgrade. The message will still appear in your logs, but it is safe to ignore.
We will add a step to the 4.0.23 upgrade to cleanup the situation in your database.