-
Notifications
You must be signed in to change notification settings - Fork 2
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
User can't deposit JSON files unless they contain valid JSON #3075
Comments
here's a branch where i tested a couple of changes suggested by @edsu in a slack discussion: i deployed and tested both on stage friday evening, but neither worked, unfortunately. related HB alert for that branch and my test case to reproduce the issue: https://app.honeybadger.io/projects/77112/faults/96288372 i set sdr-api-stage back to
|
…penapi that's rejecting user uploads of .json files with invalid json content (which gets sent in POST body, so checked by openapi according to content type
my test case on stage: https://sdr-stage.stanford.edu/works/19265 HB alert for stage, very much like the prod one for which this was filed: https://app.honeybadger.io/projects/77112/faults/96288372/ zip file that should reproduce the issue (deposit to a collection in H2, and choose the |
@andrewjbtw confirms that we don't want to accidentally validate as we're doing now: "yes, I think we should not validate that a |
@jmartin-sul and I tested a couple theories here: #3078 and sul-dlss/sdr-client#283 Basically force H2 to ignore the actual content type of the files when posting to SDR-API (via sdr-client) and just say everything is So this type of change would drop all content-types stored and shown to users and does not seem like the right approach. So possible approaches would be:
|
rails docs about parameter wrapping (the thing i tried to disable in the second commit of my sdr-api test branch from week before last): https://guides.rubyonrails.org/action_controller_overview.html#json-parameters the other thing i tried on that branch was disabling request validation by the committee gem for file uploads (see first commit). that still ran into a very similar (but slightly differently messaged) error as the original glitch. |
Basically I learned that if you post the file with The better solution is to understand how activestorage is used by sdr-api and have it not care about a content type validating the actual content of the file (like this: https://github.com/sul-dlss/sdr-api/pull/585/files) but I cannot find any details on how that works |
one more data point: @andrewjbtw and @peetucket both discovered in testing that if a user uploads a if the invalid JSON content is put in a file with a non- |
@amyehodge since solving this is turning into a bit of a thorny issue, if the depositor is eager to move there deposit through the system I believe they could change the file extension on their JSON files to .jsonl or .ndjson which are two popular file extensions used for line oriented JSON which is what they are attempting to add? The two files are:
Clearly this would not resolve this issue, but I just thought I'd share it as a possible strategy for the user since they have already been waiting a while. |
This additional test ensures that the file uploading API works. Refs sul-dlss/happy-heron#3075
This additional test ensures that the file uploading API works. Refs sul-dlss/happy-heron#3075
@peetucket hopefully it's ok if I gave this to you since you have the most viable solution in a PR at the moment? |
reproduced bug on stage one last time with the old unfixed my test deposits: running infra integration tests against stage now... |
the original |
infrastructure-integration-test suite passed against stage with the fixed H2 and sdr-api deployed (seems like no other SDR applications had been re-deployed since dep updates went out on monday). |
the fix for this issue went out with dependency updates this morning, and the user deposit on prod that originally got us to look into this behavior has now made it through: https://purl.stanford.edu/bk700vd4496 |
…case future users of sdr-api include projects that don't use sdr-client (which handles that issue automagically). see sul-dlss/happy-heron#3075
Error message
(short) Backtrace
(longer) Backtrace
View full backtrace and more info at honeybadger.io
upload fails here
content type from this response is what's used
which probably comes from
DepositJob
's original determination of file metadata here? https://github.com/sul-dlss/happy-heron/blob/398d3d6ee5da1836bc4321127a37e164bce4feba/app/jobs/deposit_job.rb#L72C1-L81possible fixes:
application/json
The text was updated successfully, but these errors were encountered: