Project

General

Profile

Actions

Defect #44051

closed

CSV import fails with `Unquoted fields do not allow new line <"\n"> in line 1` on latest trunk on Windows

Added by Yasu Saku 28 days ago. Updated 21 days ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Importers
Target version:
-
Resolution:
Fixed
Affected version:

Description

I faced a problem to import a CSV file into Redmine on Windows.

Environment

  • Redmine version 6.1.2.devel ( revision r24649 )
  • Ruby version 3.2.9-p265 (2025-07-24) [x64-mingw-ucrt]
  • Rails version 8.1.3
  • Environment development
  • Database adapter SQLite

Observed behavior

Importing a UTF-8 BOM CSV with CRLF line endings fails with the error below:

⚠️The file is not a CSV file or does not match the settings below (Unquoted fields do not allow new line <"\n"> in line 1.)

Expected behavior

The CSV should import successfully.

Comparison

The same CSV file imports successfully on 6.1.0.stable under the same Ruby/OS (Windows) environment.
Also, the latest trunk works correctly on Debian (Docker) with the same CSV file.
The issue seems to occur only on Windows.
This looks related to CSV row separator or line ending handling.
I suspect a regression around revision r24428.

Minimal reproducible CSV sample


Files

issues_csv_import_error.png (105 KB) issues_csv_import_error.png Yasu Saku, 2026-05-13 13:57
min-repro-crlf-bom.csv (47 Bytes) min-repro-crlf-bom.csv Yasu Saku, 2026-05-13 14:10

Related issues

Related to Redmine - Defect #41434: CSV import fails on CRLF files when first row has quoted field with newlineClosedGo MAEDAActions
Actions #1

Updated by Go MAEDA 27 days ago

  • Assignee set to Go MAEDA
Actions #2

Updated by Go MAEDA 26 days ago

Thank you for reporting the issue.

Could you try applying the following change to app/models/import.rb and see whether it resolves the problem?

I do not have a Windows environment available, so I cannot reproduce the issue myself. Please let me know how it goes.

diff --git a/app/models/import.rb b/app/models/import.rb
index 601b44235..42274a39d 100644
--- a/app/models/import.rb
+++ b/app/models/import.rb
@@ -279,7 +279,7 @@ class Import < ApplicationRecord
     wrapper = settings['wrapper'].to_s
     csv_options[:quote_char] = wrapper if wrapper.size == 1

-    CSV.foreach(filepath, **csv_options) do |row|
+    CSV.foreach(filepath, 'rb', **csv_options) do |row|
       yield row if block_given?
     end
   end
Actions #3

Updated by Yasu Saku 26 days ago

Thank you for the quick response and the suggested fix.

I tested the change on my Windows environment, and the CSV file could be imported successfully without any issues.

The problem appears to be resolved by opening the file in binary mode ("'rb'").

Actions #4

Updated by Go MAEDA 21 days ago

  • Related to Defect #41434: CSV import fails on CRLF files when first row has quoted field with newline added
Actions #5

Updated by Go MAEDA 21 days ago

  • Status changed from New to Closed
  • Resolution set to Fixed

Fixed the issue in r24668, as part of #41434. Thank you for your support.

Actions #6

Updated by Yasu Saku 21 days ago

Thank you as always!

Actions

Also available in: Atom PDF