Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error handling for file uploads #2012

Open
hectorcorrea opened this issue Jan 15, 2025 · 0 comments
Open

Error handling for file uploads #2012

hectorcorrea opened this issue Jan 15, 2025 · 0 comments

Comments

@hectorcorrea
Copy link
Member

While troubleshooting issue #2009 we noticed that when there is a firewall/NGINX issue uploading a file the error is reported in the wrong place. This is how it is reported when the problem is uploading the README:

upload-error-js

The problem is that when this happen the Rails application does not even get the request and it is NGINX that reports back the error and it does it as an HTML page with status code 200 (see details in #2009). We could handle these errors by updating the JavaScript that process the response.

The JavaScript code for the README is this:

uppy.use(Uppy.XHRUpload, {
      endpoint: uploadUrl,
      headers: { 'X-CSRF-Token': tokenContent },
      bundle: true, // upload all selected files at once
      formData: true, // required when bundle: true
      getResponseData(filename) {
        $('#new-readme').html(`File <b>${filename}</b> has been uploaded and set as the README for this dataset.`);
        $('#readme-upload').prop('disabled', false);
      },
    });

Notice how this code expected a filename but since the load balancer returned the error message instead we dump that message on the form.

The file upload for files other than the readme (https://github.com/pulibrary/pdc_describe/blob/main/app/javascript/entrypoints/pdc/work_edit_file_upload.es6) has the same problem except in that code we never display the error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant