TypeError: Argument 1 passed to CRM_Import_DataSource_CSV::trimNonBreakingSpaces() must be of the type string, null given in CRM_Import_DataSource_CSV::trimNonBreakingSpaces
When performing a Contact Import, if the supplied CSV file has multiple blank lines at the end of the file, then the import will abort and an error shown:
TypeError: Argument 1 passed to CRM_Import_DataSource_CSV::trimNonBreakingSpaces() must be of the type string, null given in CRM_Import_DataSource_CSV::trimNonBreakingSpaces
This error occurs when importing a CSV which has either:
- Multiple blank lines in the CSV file, CiviCRM_Contact_Search-Fails-Import-1.csv, or
- Has multiple blank lines at the end of the CSV file, CiviCRM_Contact_Search-Fails-Import-2.csv
Conversely, a CSV file will import when:
- There is only 1 blank line at the end of the CSV, CiviCRM_Contact_Search-OK-Import-2.csv, or
- No blank lines, CiviCRM_Contact_Search-OK-Import-1.csv
Confirmed in CiviCRM 5.40.4 and CiviCRM 5.41.2
PR submitted, https://github.com/civicrm/civicrm-core/pull/21638
Agileware Ref: CIVICRM-1847