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

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

Added by Yasu Saku 6 months ago. Updated 6 months 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 1 (0 open — 1 closed)

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

Updated by Go MAEDA 6 months ago Actions #1

  • Assignee set to Go MAEDA

Updated by Go MAEDA 6 months ago Actions #2

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

Updated by Yasu Saku 6 months ago Actions #3

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'").

Updated by Go MAEDA 6 months ago Actions #4

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

Updated by Go MAEDA 6 months ago Actions #5

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

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

Updated by Yasu Saku 6 months ago Actions #6

Thank you as always!

Actions

Also available in: PDF Atom