-
Notifications
You must be signed in to change notification settings - Fork 13
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
Fix invalid contributors causing crash #1771
Conversation
Currently, we assume that `Version.metadata['contributors']` is a list of JSON objects. This holds true for any metadata uploaded by the DANDI CLI, but there's nothing preventing users from uploading arbitrary JSON. Invalid JSON will be marked as invalid, but there's some places in the code where we assume it's valid anyway which results in a crash.
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.
This all looks good to me and makes sense. My only question is, is the only place in our application where these assumptions are made? If you feel confident the answer is yes then I think this is good. If you/we are unsure about that, I still think it's worth merging this now to fix the current critical bug, but we'd want to make sure to follow up.
I'm not confident that this is the only place. I initially only noticed the issue with |
🚀 PR was released in |
Dropping a thought here so it's recorded somewhere: this seems like further evidence for a need for different schemata for "draft" and "published" phases of things. In this case, we choose not to validate anything at all until we're ready for publishing, but in reality we shouldn't allowed broken formats for things like collaborators, while we should allow, e.g., missing values for certain required-at-publishing-time values (like, e.g., license). This is something that should be codified in different schemata that are applied at different times. Then, we might be able to catch people sending bad metadata etc. |
I second this. I think all contributions to the archive should be validated against an (appropriately weakened) schema and a simple error like using a dict instead of a list for the contributors field should result in a error response with an appropriate error message. It will be way easier for us if we have some semblance of order for data we receive instead of trying to handle all edge cases in query and display logic. |
Currently, we assume that
Version.metadata['contributors']
is a list of JSON objects. This holds true for any metadata uploaded by the DANDI CLI, but there's nothing preventing users from uploading arbitrary JSON. Invalid metadata will be marked as invalid, but there's some places in the code where we assume it's valid anyway which results in a crash. This PR adds some additional checks to those places to avoid outright crashes.Closes #1769