Feature #35137

Reject CSV file without data row when importing

Added by Yuichi HARADA 5 months ago. Updated 3 months ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Go MAEDA% Done:

0%

Category:Importers
Target version:5.0.0
Resolution:Fixed

Description

It is suggested to display a message indicating that there is no data when trying to import a file that has no data.

message-no-data.png (88.1 KB) Yuichi HARADA, 2021-04-21 06:38

35137.patch Magnifier (2.95 KB) Yuichi HARADA, 2021-04-21 07:06

Screenshot_2021-06-03.png (57.6 KB) Go MAEDA, 2021-06-03 11:14

35137-v2.patch Magnifier (2.91 KB) Go MAEDA, 2021-06-03 11:46

Associated revisions

Revision 21041
Added by Go MAEDA 3 months ago

Reject CSV file without data row when importing (#35137).

Patch by Yuichi HARADA.

Revision 21042
Added by Go MAEDA 3 months ago

Update locales (#35137).

History

#1 Updated by Yuichi HARADA 5 months ago

I created a patch. You get a message when you try to import a file that has only a header row.

diff --git a/app/controllers/imports_controller.rb b/app/controllers/imports_controller.rb
index 721d08fa2..2b9edfc31 100644
--- a/app/controllers/imports_controller.rb
+++ b/app/controllers/imports_controller.rb
@@ -50,7 +50,11 @@ class ImportsController < ApplicationController

   def settings
     if request.post? && @import.parse_file
-      redirect_to import_mapping_path(@import)
+      if @import.total_items == 0
+        flash.now[:error] = l(:error_no_data_import_file)
+      else
+        redirect_to import_mapping_path(@import)
+      end
     end

   rescue CSV::MalformedCSVError, EncodingError => e
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 9d779a2fe..c948d40ff 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -223,6 +223,7 @@ en:
   error_invalid_file_encoding: "The file is not a valid %{encoding} encoded file" 
   error_invalid_csv_file_or_settings: "The file is not a CSV file or does not match the settings below (%{value})" 
   error_can_not_read_import_file: "An error occurred while reading the file to import" 
+  error_no_data_import_file: "There is no data to import into the file" 
   error_attachment_extension_not_allowed: "Attachment extension %{extension} is not allowed" 
   error_ldap_bind_credentials: "Invalid LDAP Account/Password" 
   error_no_tracker_allowed_for_new_issue_in_project: "The project doesn't have any trackers for which you can create an issue" 

#2 Updated by Go MAEDA 4 months ago

Users can run the import after configuring the field mapping, even if the CSV file contains only a header row.

However, after running the import of the CSV file, only a blank page is displayed (see Screenshot_2021-06-03.png). I think it is confusing and difficult to troubleshoot for some users.

I think it would be helpful to display an appropriate error message so as not to confuse users.

#3 Updated by Go MAEDA 4 months ago

  • File 35137-v2.patch added
  • Subject changed from Display a message indicating that there is no data to Reject CSV file without data row when importing

Changed the error message in the patch.

#4 Updated by Go MAEDA 4 months ago

  • File deleted (35137-v2.patch)

#5 Updated by Go MAEDA 4 months ago

#6 Updated by Go MAEDA 3 months ago

  • Target version changed from Candidate for next major release to 5.0.0

Setting the target version to 5.0.0.

#7 Updated by Go MAEDA 3 months ago

  • Status changed from New to Closed
  • Assignee set to Go MAEDA
  • Resolution set to Fixed

Committed the patch. Thank you.

Also available in: Atom PDF