[Bug 44103] New: file-upload.js needs checking on Ajax http status
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44103 Bug ID: 44103 Summary: file-upload.js needs checking on Ajax http status Initiative type: --- Sponsorship --- status: Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: normal Priority: P5 - low Component: Tools Assignee: koha-bugs@lists.koha-community.org Reporter: m.de.rooy@rijksmuseum.nl QA Contact: testopia@bugs.koha-community.org Target Milestone: --- The onload assumes that it receives a JSON response, but when for instance Apache or a reverse proxy before Apache blocks it for response body size, you wont have a JSON response at all. In my case I uploaded a file that was only a few MB larger than the limit resulting in a 100% progress silently failing. Only a careful look at dev tools would show a 413 Entity too large. -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44103 Marcel de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED Assignee|koha-bugs@lists.koha-commun |m.de.rooy@rijksmuseum.nl |ity.org | -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44103 Marcel de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |Needs Signoff Patch complexity|--- |Small patch -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44103 --- Comment #1 from Marcel de Rooy <m.de.rooy@rijksmuseum.nl> --- Created attachment 211595 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=211595&action=edit Bug 44103: Add check on Ajax http status in file-upload.js This is a least work-solution. Probably this needs to move to fetch API etc. Note that it was a bit hard to get to the exact file name of the failing upload when doing a multi file upload. Test plan: Check what your max request body is for Apache or your reverse proxy before Apache etc. (By default 100MB in Apache.) Upload a larger file via Tools/Upload in staff view. Verify that you receive an error message like: FILE_NAME: Something went wrong during the Ajax upload: An uploaded file was too large. Note that if you would upload multiple files including the larger one, you will see: FILE1,FILE2: <same messag> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44103 Marcel de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #211595|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44103 --- Comment #2 from Marcel de Rooy <m.de.rooy@rijksmuseum.nl> --- Created attachment 211596 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=211596&action=edit Bug 44103: Add check on Ajax http status in file-upload.js This is a least work-solution. Probably this needs to move to fetch API etc. Note that it was a bit hard to get to the exact file name of the failing upload when doing a multi file upload. Test plan: Check what your max request body is for Apache or your reverse proxy before Apache etc. (By default 100MB in Apache.) Upload a larger file via Tools/Upload in staff view. Verify that you receive an error message like: FILE_NAME: Something went wrong during the Ajax upload: An uploaded file was too large. Note that if you would upload multiple files including the larger one, you will see: FILE1,FILE2: <same message> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44103 Marcel de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |dcook@prosentient.com.au -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44103 --- Comment #3 from Marcel de Rooy <m.de.rooy@rijksmuseum.nl> --- Info for QA: Checking other occurrences of AjaxUpload: koha-tmpl/intranet-tmpl/prog/en/modules/offline_circ/process_koc.tt: xhr = AjaxUpload($("#fileToUpload"), $("#fileuploadprogress"), "temp=1", cbUpload); Just wondering if the cbUpload else branch works here (but out of scope; the status failed or denied is passed). $("#fileuploadfailed").text(_("Upload status: ") + (status == "failed" ? _("Failed") + " - (" + errCode + ") " + errMsgs[errCode] : status == "denied" ? _("Denied") : status)); Does that work: errMsgs[errCode] ? koha-tmpl/intranet-tmpl/prog/en/modules/tools/import_borrowers.tt: xhr = AjaxUpload($("#fileToUpload"), $("#fileuploadprogress"), "temp=1", cbUpload); Same code as in process_koc.tt. Same doubts. koha-tmpl/intranet-tmpl/prog/en/modules/tools/stage-marc-import.tt: xhr = AjaxUpload($("#fileToUpload"), $("#fileuploadprogress"), "temp=1", cbUpload); Again same code. koha-tmpl/intranet-tmpl/prog/js/upload-images.js:function AjaxUpload(formData, progressbar, xtra, callback) { This template redefines the AjaxUpload (actually some kind of copy-paste containing the same error of not checking the JSON parse). And note that cbUpload here is a reformatted version of the process_koc.tt code. So dubious. Will try to add a small follow-up here still. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44103 Marcel de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |BLOCKED -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44103 Marcel de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|BLOCKED |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44103 Marcel de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #211596|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44103 --- Comment #4 from Marcel de Rooy <m.de.rooy@rijksmuseum.nl> --- Created attachment 211604 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=211604&action=edit Bug 44103: Add check on Ajax http status in file-upload.js This is a least work-solution. Probably this needs to move to fetch API etc. Note that it was a bit hard to get to the exact file name of the failing upload when doing a multi file upload. Test plan: Check what your max request body is for Apache or your reverse proxy before Apache etc. (By default 100MB in Apache.) Upload a larger file via Tools/Upload in staff view. Verify that you receive an error message like: FILE_NAME: Something went wrong during the Ajax upload: An uploaded file was too large. Note that if you would upload multiple files including the larger one, you will see: FILE1,FILE2: <same message> Test another script using this js code: Go to tools/stage-marc-import.pl (via Cataloguing). Upload the same larger file. You see: Upload status: Denied. Note: This could surely be extended (but not here). Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44103 --- Comment #5 from Marcel de Rooy <m.de.rooy@rijksmuseum.nl> --- Created attachment 211605 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=211605&action=edit Bug 44103: (follow-up) Similar change for alternative AjaxUpload in upload-images.js Using this opportunity to rename this AjaxUpload to AjaxImageUpload to make a distinction between the two. I added a FIXME for the error processing in cbUpload. The logic used is the same as in a few other js files, but is just wrong. Correcting that is outside the scope of this bug. Opened a new bug. Test plan: Upload an image with upload-images that is larger than the max request body. Verify that it does not silently fail but shows the error: Upload status: Failed - (AJAX_FAILURE) Note: This message should be enhanced on a follow-up report. Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44103 --- Comment #6 from Marcel de Rooy <m.de.rooy@rijksmuseum.nl> --- Decided to rework the first patch with the try..catch block from the second. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44103 Marcel de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|file-upload.js needs |file-upload.js should not |checking on Ajax http |assume that it receives a |status |JSON response -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44103 Marcel de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #211605|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44103 --- Comment #7 from Marcel de Rooy <m.de.rooy@rijksmuseum.nl> --- Created attachment 211606 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=211606&action=edit Bug 44103: Add check around JSON.parse in file-upload.js This is a least work-solution. Probably this needs to move to fetch API etc. Note that it was a bit hard to get to the exact file name of the failing upload when doing a multi file upload. Test plan: Check what your max request body is for Apache or your reverse proxy before Apache etc. (By default 100MB in Apache.) Upload a larger file via Tools/Upload in staff view. Verify that you receive an error message like: FILE_NAME: Something went wrong during the Ajax upload: An uploaded file was too large. Note that if you would upload multiple files including the larger one, you will see: FILE1,FILE2: <same message> Test another script using this js code: Go to tools/stage-marc-import.pl (via Cataloguing). Upload the same larger file. You see: Upload status: Denied. Note: This could surely be extended (but not here). Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44103 --- Comment #8 from Marcel de Rooy <m.de.rooy@rijksmuseum.nl> --- Created attachment 211607 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=211607&action=edit Bug 44103: (follow-up) Similar change for alternative AjaxUpload in upload-images.js Main goal of this patch ia adding the same check around JSON.parse. Note that this AjaxUpload is a slightly changed copy/paste. Using this opportunity to rename this AjaxUpload to AjaxImageUpload to make a distinction between the two. I added a FIXME for the error processing in cbUpload. The logic used is the same as in a few other js files, but is just wrong. Correcting that is outside the scope of this bug. Opened a new bug. Test plan: Upload an image with upload-images that is larger than the max request body. Verify that it does not silently fail but shows the error: Upload status: Failed - (AJAX_FAILURE) Note: This message should be enhanced on a follow-up report. Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44103 Marcel de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #211604|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44103 Marcel de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jonathan.druart@gmail.com See Also| |https://bugs.koha-community | |.org/bugzilla3/show_bug.cgi | |?id=42025 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44103 Marcel de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://bugs.koha-community | |.org/bugzilla3/show_bug.cgi | |?id=44106 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44103 Marcel de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://bugs.koha-community | |.org/bugzilla3/show_bug.cgi | |?id=44113 -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org