How do I load entities with null values?


The exception is the result of how EntityStorageBase::loadByProperties() build the underlying WHERE clause; is using ::buildPropertyQuery() which throws NULL to an array then use the IN operator to compare; this will not work since you need a IS NULL query to find NULL entries in the DB.

Instead, you can create your own entity storage query similarly to loadByProperties():

$es = Drupal::entityTypeManager()->getStorage('foo_module_division')
$q = $es->getQuery();
$results = $q->condition('parent_code', NULL, 'IS')->condition('enabled', TRUE)->execute();
return $results ? $es->loadMultiple($results) : array();