Skip to content

Strip undefined attributes during StudyFile creation (SCP-5996) #2265

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

Merged
merged 3 commits into from
May 27, 2025

Conversation

bistline
Copy link
Contributor

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:

(Mongoid::Errors::UnknownAttribute)
message:
  Attempted to set a value for 'raw_location' which is not allowed on the model ExpressionFileInfo.

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.

@bistline bistline requested a review from eweitz May 27, 2025 18:07
Copy link

codecov bot commented May 27, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 71.03%. Comparing base (a42dab6) to head (6bd9cdf).
Report is 7 commits behind head on development.

Additional details and impacted files

Impacted file tree graph

@@               Coverage Diff               @@
##           development    #2265      +/-   ##
===============================================
+ Coverage        71.01%   71.03%   +0.01%     
===============================================
  Files              335      335              
  Lines            28820    28832      +12     
  Branches          2527     2527              
===============================================
+ Hits             20466    20480      +14     
+ Misses            8213     8211       -2     
  Partials           141      141              
Files with missing lines Coverage Δ
app/controllers/api/v1/study_files_controller.rb 86.05% <100.00%> (+0.36%) ⬆️

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@bistline bistline merged commit 9f5aeb9 into development May 27, 2025
6 checks passed
@github-actions github-actions bot deleted the jb-raw-location-classic-upload branch May 27, 2025 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants