Fix nil @submission in OntologyProcessor when metadata extraction bails#283
Open
Fix nil @submission in OntologyProcessor when metadata extraction bails#283
Conversation
SubmissionMetadataExtractor#extract_metadata used a bare `return` when the submission failed validation, returning nil. OntologyProcessor assigned that nil back over its own @submission, so the ensure-block call to notify_submission_processed raised NoMethodError on nil.archived? -- which its inner rescue logged as the misleading "Email sending failed: undefined method `archived?' for nil:NilClass". - submission_extract_metadata.rb: return @submission on the invalid path so the method has a consistent return value. - submission_processor.rb: stop reassigning @submission from the extract_metadata return value; the extractor mutates the shared instance in place via @submission.save. - submission_processor.rb: guard notify_submission_processed against a nil @submission so a missing submission can't surface as the misleading "Email sending failed" log line. - Add regression test reproducing the full path.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Fixes the misleading log line observed on
ncbo_cronwhen processing ontologies:That error was a symptom — the real failure was upstream in metadata extraction.
Root cause
SubmissionMetadataExtractor#extract_metadataused a barereturnon theunless @submission.valid?branch, so it returnednilfor invalid submissions.OntologyProcessor#process_submissiondid@submission = @submission.extract_metadata(...), overwriting its own submission reference with thatnil.@submission.*calls then failed. In theensureblock,notify_submission_processedinvoked@submission.archived?onnil, and its innerrescuelogged the misleading"Email sending failed: ..."line.Changes
submission_extract_metadata.rb:return @submissionon the invalid path so the method has a consistent return value.submission_processor.rb: stop reassigning@submissionfrom theextract_metadatareturn value — the extractor already mutates the shared instance via@submission.save.submission_processor.rb:return if @submission.nil?guard innotify_submission_processed, so a missing submission can't surface as the misleading log line again.test/services/test_submission_processor.rbreproducing the exact path.Test plan
developwithNoMethodError: undefined method 'save' for nil:NilClass(confirmed by reverting the fixes locally).rake test:docker:fs).rake test:docker:fsrun on this branch before merge.