Skip to content

Fix NoneType crash in test_gapfill_database when media is None#24

Open
jplfaria wants to merge 1 commit intocshenry:mainfrom
jplfaria:fix-gapfill-none-media
Open

Fix NoneType crash in test_gapfill_database when media is None#24
jplfaria wants to merge 1 commit intocshenry:mainfrom
jplfaria:fix-gapfill-none-media

Conversation

@jplfaria
Copy link
Copy Markdown

Summary

  • MSGapfill.test_gapfill_database() crashes with AttributeError: 'NoneType' object has no attribute 'id' when media=None (Complete media) and gapfilling fails to find a solution
  • The error path (lines 138-156) accesses media.id without a None check to record gf_sensitivity and log a warning
  • Fix: extract media.id into a local media_id variable with fallback to "Complete" before using it

Reproduction

from modelseedpy import MSGapfill

gapfiller = MSGapfill(model, default_target="bio1", default_gapfill_templates=[template])
# Crashes when no solution is found and media is None:
solution = gapfiller.run_gapfilling(media=None)
# -> AttributeError: 'NoneType' object has no attribute 'id'

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 returning None gracefully.

We have a workaround in the API (passing MSMedia("Complete", "Complete") instead of None), but the upstream fix is a one-line change.

🤖 Generated with Claude Code

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>
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.

1 participant