Fix NoneType crash in test_gapfill_database when media is None#24
Open
jplfaria wants to merge 1 commit intocshenry:mainfrom
Open
Fix NoneType crash in test_gapfill_database when media is None#24jplfaria wants to merge 1 commit intocshenry:mainfrom
jplfaria wants to merge 1 commit intocshenry:mainfrom
Conversation
test_gapfill_database() accesses media.id in the error path (lines 138-156) without checking if media is None. When gapfilling is called with media=None (Complete media) and no solution is found, this crashes with: AttributeError: 'NoneType' object has no attribute 'id' Fix: extract media.id into a local variable with fallback to "Complete" before using it in the gf_sensitivity dict and log message. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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
MSGapfill.test_gapfill_database()crashes withAttributeError: 'NoneType' object has no attribute 'id'whenmedia=None(Complete media) and gapfilling fails to find a solutionmedia.idwithout a None check to record gf_sensitivity and log a warningmedia.idinto a localmedia_idvariable with fallback to"Complete"before using itReproduction
Context
Found this while building the new ModelSEED REST API. When users run gapfilling with Complete media (no media restriction,
media=None), and the solver can't find a solution, the error/sensitivity recording path crashes instead of returningNonegracefully.We have a workaround in the API (passing
MSMedia("Complete", "Complete")instead ofNone), but the upstream fix is a one-line change.🤖 Generated with Claude Code