Not a question as such, rather an observation. WordPress contacts import from CSV, CiviCRM 5.61.2. (not reproduceable on dmaster).

Uncaught TypeError: Return value of CRM_Contact_Import_Form_MapField::getLocationTypeLabel() must be of the type string, null returned in www/wp-content/plugins/civicrm/civicrm/CRM/Contact/Import/Form/MapField.php:480

1 Answer 1


UPD: Apparently this happens if some Location Types have no Labels.

Rather simple fix: change from

  • protected function getLocationTypeLabel($type): string {


  • protected function getLocationTypeLabel($type): ?string {

in www/wp-content/plugins/civicrm/civicrm/CRM/Contact/Import/Form/MapField.php:480

however not sure it's the right thing to do.

  • The question really is whether it is valid not to have a label. If it is, then it should probably return an empty string rather than null so changing the next line may be better to become: return $this->getLocationTypes()[$type] ?? ''; Since it is not causing a problem on master then it may have been addressed in a different way already but if you want to post a PR someone will review and either accept your change or suggest a better way - be sure to include a valid scenario where the label is blank.
    – Aidan
    Commented Jul 31, 2023 at 14:49
  • I don't think it is possible to have an address location type without a label. It's a required field. Do you have an address type without a label? If not, it sounds like something else is broken.
    – Lars SG
    Commented Jul 31, 2023 at 16:30
  • Aidan, LarsSG : thank you for pointers, now I realise where this came from (empty Location Type labels) - thought initially this is because Primary location type has been disabled ( not deleted ) at /wp-admin/admin.php?page=CiviCRM&q=civicrm%2Fadmin%2FlocationType&reset=1 Not sure why this has been configured like so, however it throws an error so maybe worth patching one way or another.
    – yurg
    Commented Aug 1, 2023 at 9:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.