Strip undefined attributes during StudyFile creation (SCP-5996) #2265
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
BACKGROUND & CHANGES
This addresses a rare corner case where a user attempted to upload a classic plain text expression matrix file and encountered the following error:
This should not be possible, as
raw_location
is only present in the AnnData UX. The associated error report also shows that no upload is being provided by the user, so it is unclear how they got into this state.Now, when a StudyFile is being processed by the API, a final sanitization step will run that strips out all key/value pairs that are not defined fields for either the StudyFile or any of the nested associations (ExpressionFileInfo, AnnDataFileInfo, etc). This will remove the need to manually prune any extra fields that are added to forms that don't map to model attributes, such as control-oriented fields like
parse_on_upload
.MANUAL TESTING
Since it is unclear how the user got into this state, and all attempts to recreate it have failed, there is not currently a way to manually test as the Swagger API documentation does not allow adding additional fields. You could try directly via
cURL
, but this seems overly complicated as it requires reconstructing the exact form structure for the POST.