CDLUC3 / dmptool

DMPTool version of the DMPRoadmap codebase
https://dmptool.org
MIT License
56 stars 13 forks source link

Cannot upload a DMP over 250KB despite displayed limit being 1MB #611

Closed bofstein closed 1 week ago

bofstein commented 1 week ago

Describe the bug When starting a new Upload Plan flow, if a PDF is attached the flow will not continue passed the New Plan phase

To Reproduce Go to the Stage DMP Tool site Log in with an admin account Click Upload Plan Click Add Plan Add a Project Name Click Choose File and select a valid DMP PDF under 1MB Click Save & Continue Observe that the page does not advance, stays on that page. No error message is shown. Network logs show a 400 error

Expected behavior I expect it to move on to the next page in the upload flow

Screenshots image

Additional context If you don't have a PDF it works fine to continue

jupiter007 commented 1 week ago

@bofstein I tried to reproduce this on Staging using Chrome, and was able to click "Save and Continue" and get to the subsequent steps in the flow.

I also ran the app locally, and was able to progress as well.

Could you try again but in incognito mode to see if that makes a difference?

jupiter007 commented 1 week ago

I was able to reproduce when I used a PDF that was generated by the new Grover/Puppeteer PDF generator

Hakai_Institute_Juvenile_Salmon_Program_Time_Series_created_with_Grover.pdf

vThe error indicates that the file size is too big: API V3 ERROR: status: bad_request, errors: ["Narrative PDF too large, must be less than 350KB"], even though my Finder indicates that the file size is only 261KB.

It looks like in app/models/draft.rb, we are actually setting the limit to 250kb.

# Validate that the attachment is a PDF and that it is less than 250KB
  validates :narrative, size: { less_than: 250.kilobytes , message: 'PDF too large, must be less than 350KB' },
                        content_type: { in: ['application/pdf'], message: 'must be a PDF document' }

We need to find out whether there was a reason to set the limit to 250k. Also, Becky mentioned that "we should look into what we're doing in the new PDF generator to get that high - the old one for the same DMP was only 48KB, while the new one is 255."

bofstein commented 1 week ago

Initial actions to take for this ticket:

Future actions in another ticket will be adding warning messages and looking into making PDFs smaller