I had a batchable class MyBatchable whose unit tests have been running successfully for over 2 years and suddenly, they stopped working yesterday with error

Batch Apex Unit Test: System.UnexpectedException: Error processing messages

Looking at the debug log, it appears that the start() method fails to return any rows to execute() - even though it should return rows.

I looked at the other problem reasons in these answers

1 Answer 1


The fact that the start() method failed was the clue because ...

  • I had recently introduced into the batchable start's QueryLocator the field OrderItem.Product2Id
  • The batchable class was written as of V38.0
  • The field OrderItem.Product2Id needs the Database.getQueryLocator() method to be executing with at least V40.0 to not cause the error.

Updating the batchable class to V56.0 solved the issue

We could generalize that referencing a standard field not introduced until Vxx can not be used in a batchable's getQueryLocator method if batchable is running at Vxx-n, n >= 1 but I did not test this generalization.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .