octobercms/october · error · ApplicationException
Source file encoding is not recognized. Please select the…
Error message
Source file encoding is not recognized. Please select the custom file format option with the proper encoding to import your file.
What it means
getImportFileColumnsFromCsv json_encodes the first CSV row purely to detect encoding problems; when json_encode fails (invalid UTF-8 etc.) it throws this ApplicationException telling the user to pick a custom file format with the correct encoding — the uploaded file's charset is at fault.
Solutions
- Re-save/export the source file as UTF-8 before importing
- Choose the custom file format option and select the file's actual encoding
- Strip BOM/invalid byte sequences from the CSV
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at modules/backend/behaviors/importexportcontroller/CanFormatCsv.php:32 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of octobercms/october@b608633a7e (2026-08-21).
Data as JSON: /api/errors/81e3a771add978b1.
Report an issue: GitHub.
Appendix: source
Thrown at modules/backend/behaviors/importexportcontroller/CanFormatCsv.php:32
trait CanFormatCsv
{
/**
* getImportFileColumnsFromCsv path
*/
protected function getImportFileColumnsFromCsv($path)
{
$reader = $this->createCsvReader($path);
$firstRow = $reader->fetchOne(0);
if (!post('first_row_titles')) {
array_walk($firstRow, function (&$value, $key) {
$value = 'Column #'.($key + 1);
});
}
// Prevents unfriendly error to be thrown due to bad encoding at response time.
if (json_encode($firstRow) === false) {
throw new ApplicationException(__("Source file encoding is not recognized. Please select the custom file format option with the proper encoding to import your file."));
}
return $firstRow;
}
/**
* getImportSampleColumnsFromCsv
*/
protected function getImportSampleColumnsFromCsv($path, $columnIndex)
{
$reader = $this->createCsvReader($path);
if (post('first_row_titles')) {
$reader->setHeaderOffset(0);
}
$result = (new CsvStatement)
->limit(50)View on GitHub (pinned to b608633a7e)