-
Notifications
You must be signed in to change notification settings - Fork 41
patch: file upload errors #1351
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
base: main
Are you sure you want to change the base?
Conversation
} catch (err) { | ||
if (err.data?.res) { | ||
const { error } = uploadService.parsedDocumentUploadResponse(err.data); | ||
request.pre.errors = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please keep since we don't want to lose any errors that have accumulated up to this point
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jenbutongit Is it safe to delete error writing in the if (error) on line 102 instead?
And is keeping "response = uploadService.parsedDocumentUploadResponse(err.data);" okay? I've done this so "const { location, warning, error } = response;" can unpack
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doing it in this way will result in the error being added to request.pre.errors twice (when an error is thrown) - you add response.error in the catch, then unpack the response and add it again in the if(error) block. Do you need the response when an error is thrown? (e.g. are you using location
or warning
?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@superafroman Do you want to resolve/review since the implementation has changed? My initial comment is also redundant.
As a side note - I've noticed an issue with the code (not introduced by this change). uploadService.parsedDocumentUploadResponse
is called internally in uploadService, but is called again on err.data. We have httpService.request
(and httpService.post
) which looks like it wants to suppress the thrown error and return it in an object instead
Looking at uploadService.uploadDocuments
- I think the intention is that it returns an object containing { location, error, warning }
if there was a document upload API error but is never called since post request throws.
I'm fine to resolve this in another PR/issue though.
0a6a60e
to
b27653c
Compare
b27653c
to
741d35c
Compare
loggerIdentifier, | ||
`Document upload API responded with an error ${error}` | ||
); | ||
errors.add(error); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be omitted, since it's handled in l51-53. I think that should remove the need for the set as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you have an error which doesn't go into the catch block, then it will not be added to the errors list (which is how the file upload tests work) so it needs to be added here
as an fyi - attaching the file I'm using to test different error cases files.json I'm also testing with https://github.com/UKForeignOffice/document-upload I'm testing these regressions
|
Note
This template is designed to help both contributors and maintainers. It is a checklist to ensure all necessary
information is provided, and prompts contributors on any contribution guidelines they have missed.
Do not remove sections.
They are important for the review process and help maintainers ensure quality and good documentation across the
project.
Some checkboxes will not apply to every change, so feel free to leave them unchecked if they are not relevant.
Description
Context
Changes
Repairing ability for errors received from the upload response to show on the page rather than going to the 500 page
Stopping that error from being shown twice
Adding a new error for when too many files are uploaded
Changing mention of file to files and removing the field name to match GDS
Type of change
What is the type of change you are making?
PR title
PR titles should be prefixed with the type of change you are making, based on the README.md#versioning.
This is so that when performing a squash merge, the PR title is automatically used as the commit message.
Have you updated the PR title to match the type of change you are making?
Testing
Automated tests
Have you added automated tests?
Manual tests
Have you manually tested your changes?
Have you attached an example form JSON or snippet for the reviewer in this PR?
Steps to test
Documentation
Have you updated the documentation?
Discussion
Warning
Large or complex changes may require discussion with the maintainers before they can be merged. If it has not yet been discussed, it may delay the review process
Have you discussed this change with the maintainers?