Bug 27869

Summary: QotD CSV upload JavaScript errors
Product: Koha Reporter: Lucas Gass <lucas>
Component: ToolsAssignee: Lucas Gass <lucas>
Status: CLOSED FIXED QA Contact: Joonas Kylmälä <joonas.kylmala>
Severity: minor    
Priority: P5 - low CC: fridolin.somers, jonathan.druart, joonas.kylmala
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
This patch handles malformed CSV errors by producing a warning on the page letting users know that the CSV filed uploaded has errors.
Version(s) released in:
21.05.00
Bug Depends on: 27251    
Bug Blocks:    
Attachments: Bug 27869: let user know something went wrong with csv upload
bad_example.csv
Bug 27869: let user know something went wrong with csv upload
Bug 27869: let user know something went wrong with csv upload

Description Lucas Gass 2021-03-04 19:25:18 UTC
On /cgi-bin/koha/tools/quotes-upload.pl if you upload a CSV that is not quite right the page produces a javascript error:

Uncaught TypeError: arrData[(arrData.length - 1)] is undefined

To the user this is confusing as #quotes_editor table visibility remains hidden and the progress bar says 100%. 

Can we handle this error better? Maybe a warning on the screen letting the user know something is wrong?
Comment 1 Lucas Gass 2021-03-04 19:43:12 UTC
Created attachment 117760 [details] [review]
Bug 27869: let user know something went wrong with csv upload

To test:
-attempt to upload a malformed CSV file
-nothing happens, check the console and see the error: Uncaught TypeError: arrData[(arrData.length - 1)] is undefined
-apply patch
-try again
-now you should at least see a warning that something went wrong
-attempt to upload a good CSV file, it should work
Comment 2 Owen Leonard 2021-03-05 14:26:42 UTC
(In reply to Lucas Gass from comment #1)
> -attempt to upload a malformed CSV file

Can you suggest how to make it malformed?
Comment 3 Lucas Gass 2021-03-05 20:17:01 UTC
Created attachment 117875 [details]
bad_example.csv
Comment 4 Lucas Gass 2021-03-05 20:17:22 UTC
(In reply to Owen Leonard from comment #2)
> (In reply to Lucas Gass from comment #1)
> > -attempt to upload a malformed CSV file
> 
> Can you suggest how to make it malformed?

I have attached an example file.
Comment 5 David Nind 2021-03-08 19:19:06 UTC
Created attachment 117949 [details] [review]
Bug 27869: let user know something went wrong with csv upload

To test:
-attempt to upload a malformed CSV file
-nothing happens, check the console and see the error: Uncaught TypeError: arrData[(arrData.length - 1)] is undefined
-apply patch
-try again
-now you should at least see a warning that something went wrong
-attempt to upload a good CSV file, it should work

Signed-off-by: David Nind <david@davidnind.com>
Comment 6 Joonas Kylmälä 2021-04-01 11:47:05 UTC
Created attachment 119071 [details] [review]
Bug 27869: let user know something went wrong with csv upload

To test:
-attempt to upload a malformed CSV file
-nothing happens, check the console and see the error: Uncaught TypeError: arrData[(arrData.length - 1)] is undefined
-apply patch
-try again
-now you should at least see a warning that something went wrong
-attempt to upload a good CSV file, it should work

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Joonas Kylmälä <joonas.kylmala@helsinki.fi>
Comment 7 Jonathan Druart 2021-04-01 16:54:26 UTC
Pushed to master for 21.05, thanks to everybody involved!
Comment 8 Fridolin Somers 2021-04-15 10:20:01 UTC
Looks like it depends a bit on Bug 27251 not in 20.11.x

Not pushed to 20.11.x