fix(spp_programs): handle state=None in enroll eligible async dispatch#173
Merged
gonzalesedwin1123 merged 2 commits into19.0from Apr 27, 2026
Merged
Conversation
The "Enroll Eligible" button calls enroll_eligible_registrants() with no argument, so state defaults to None. When the program has at least MIN_ROW_JOB_QUEUE (200) beneficiaries, the async path runs and called tuple(states) on None, raising TypeError. Mirror get_beneficiaries semantics: when states is None/empty, omit the "state IN %s" filter from the SQL where-clause so all states are considered. Add a regression test that covers state=None.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 19.0 #173 +/- ##
=======================================
Coverage 71.47% 71.48%
=======================================
Files 932 932
Lines 54835 54840 +5
=======================================
+ Hits 39196 39201 +5
Misses 15639 15639
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Code Review
This pull request updates the _enroll_eligible_registrants_async method to handle cases where the states parameter is None or empty. It dynamically adjusts the SQL where_clause and parameters to avoid a TypeError when attempting to convert None to a tuple. A new test case has been added to verify that the method correctly omits the state filter when no states are provided. I have no feedback to provide.
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
programs.py:399) callsenroll_eligible_registrants()with no argument, sostatedefaults toNone. When the program has>= MIN_ROW_JOB_QUEUE(200) beneficiaries, dispatch goes through_enroll_eligible_registrants_async, which calledtuple(states)onNoneand raisedTypeError: 'NoneType' object is not iterable.Nonebecauseprogram.get_beneficiaries(state=None, ...)already treats it as "all states" — only the async path crashed, which is why this only reproduced on programs with many registrants.get_beneficiariessemantics — whenstatesisNone/empty, build the SQL where-clause without thestate IN %sfilter and pass only(program.id,)tocompute_id_ranges.Traceback (before fix)
Test plan
test_enroll_eligible_async_handles_none_statefails before the fix and passes after — verifies noTypeError, and thatcompute_id_rangesis called with a where-clause that omitsstate INand params equal to(program.id,).spp_programstest suite passes: 637/637.test_enroll_eligible_async_handles_string_stateandtest_enroll_eligible_async_uses_compute_id_rangesstill pass (states-as-string and states-as-list paths unaffected).pre-commitclean on changed files.