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

Validation errors on upload content should return a 4xx #3138

Closed
chrisvanrun opened this issue Dec 14, 2023 · 7 comments · Fixed by #3156
Closed

Validation errors on upload content should return a 4xx #3138

chrisvanrun opened this issue Dec 14, 2023 · 7 comments · Fixed by #3156

Comments

@chrisvanrun
Copy link
Contributor

Was working on testing an upload script and got back the following:

image

IMHO a client-side error is more appropriate here: for instance 415 Unsupported Media Type

@jmsmkn
Copy link
Member

jmsmkn commented Dec 14, 2023

Err, 500 error means that you broke it and there will be an unhandled exception, probably this (https://grand-challenge.sentry.io/issues/4725383151/?project=303639&query=%21logger%3Acsp+is%3Aunresolved&referrer=issue-stream&statsPeriod=30d&stream_index=1)? There are other similar ones there. Can you provide a test in GC to reproduce?

@chrisvanrun
Copy link
Contributor Author

I found out wat went wrong via Sentry initially.

Am I reading it wrong? It seems like a ValidationError on the content of the patch (i.e. a JSON schema not matching) results in a 500 error?

@jmsmkn
Copy link
Member

jmsmkn commented Dec 14, 2023

The problem is likely that the validation error is raised in the incorrect place, is then unhandled. A test would reveal it.

@chrisvanrun
Copy link
Contributor Author

Possibly sidely related to:

@amickan
Copy link
Contributor

amickan commented Dec 15, 2023

Yes, common issue. For display sets, this is solved by doing validation for file type interfaces in an async task in an atomic block. If validation fails, we send a notification to the user with the error message and the CIV does not get created. For archives items and algorithm jobs, we do the validation synchronously, but don't catch the validation error appropriately.

One way of validating files would be good. As such I think this ties in with https://github.com/DIAGNijmegen/rse-roadmap/issues/274

I'm now wondering if doing this asynchronously is really necessary. It would arguably be more user friendly if we validate the file contents against any possible json schema synchronously and return the error to the user in the form. That should be fast enough to do synchronously. For non json files we don't validate anything (except for checking wether the upload is complete), so no need for an asynch task for this either. Am I missing something?

@jmsmkn
Copy link
Member

jmsmkn commented Dec 15, 2023

It needs to be async for multi-X JSON files as you can have things with millions of entries, you could DOS the API layer with that if it were in place. Same for things in values as we allow large inputs at the HTTP layer.

@amickan
Copy link
Contributor

amickan commented Dec 15, 2023

Ok, yes, asynch it is then. The algorithm and archive item code base need to be updated then. Best to have one place where this is all handled and then use that everywhere. Not sure how far I'll get before my vacation, but as I said this is anyway part of the larger pitch I linked above. Appetite feels big for this pitch with all the issues we've been encountering lately.

amickan added a commit that referenced this issue Jan 11, 2024
…play sets (#3156)

Closes #3138 
Part of DIAGNijmegen/rse-roadmap#274 

With this change to use the same logic and code for CIV creation for
display sets and archive items, it is no longer possible to update the
interface of an image in an archive item. We already discussed this
[here ](#3116
and had decided that this was no longer necessary.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants