Merge changes I54ea7a71,Ifd9c54fd into main

* changes:
  Set task properties to prevent the task being null. This behaviour is expected by existing callers and was likely broken by ag/28151977
  TaskRepository performance improvement