Description
esp/esp/program/modules/handlers/programprintables.py can crash in paid_list() when the filter query parameter contains a non-integer value.
Why this matters
The paid-list printable is an admin workflow used to review program charges and payments. A malformed or tampered filter value should fall back safely or raise a clean user-facing error, not crash the page.
Right now, the handler tries to parse request.GET.getlist('filter') as integers. If any value fails integer conversion, it sets ids = None, but then stores the fallback queryset in transfers instead of lineitems. A few lines later, the code always iterates over lineitems, which is undefined in that branch.
This means a bad filter value can trigger an exception instead of rendering the printable.
Evidence
Relevant code:
esp/esp/program/modules/handlers/programprintables.py
Current control flow in paid_list():
- parse
request.GET.getlist('filter')
- on
ValueError, set:
ids = None
single_select = False
- then in the
ids is None branch assign:
- but later always do:
for lineitem in lineitems:
Because lineitems is not assigned in that fallback branch, the function can raise an exception before rendering.
Steps to Reproduce
- Open
esp/esp/program/modules/handlers/programprintables.py.
- Locate
paid_list().
- Follow the branch where:
'filter' in request.GET
- integer conversion raises
ValueError
- Observe that the fallback queryset is assigned to
transfers, not lineitems.
- Observe that the function later iterates over
lineitems unconditionally.
A request like this should hit the bad path:
...?filter=abc
Expected Behavior
If filter contains an invalid value, the handler should either:
- fall back to the unfiltered paid list, or
- show a clean user-facing error
It should not crash.
Actual Behavior
An invalid filter value can leave lineitems undefined and cause the handler to fail before rendering the page.
Impact
This is a real crash path in an admin printable workflow. It can be triggered by malformed query parameters, stale links, or manual URL edits.
Suggested Fix
In the invalid-filter fallback branch, assign the queryset to lineitems instead of transfers, or otherwise normalize the branches so the later code always works with the same variable.
Additional Context
Verified against current main by inspecting paid_list() in:
esp/esp/program/modules/handlers/programprintables.py
Description
esp/esp/program/modules/handlers/programprintables.pycan crash inpaid_list()when thefilterquery parameter contains a non-integer value.Why this matters
The paid-list printable is an admin workflow used to review program charges and payments. A malformed or tampered
filtervalue should fall back safely or raise a clean user-facing error, not crash the page.Right now, the handler tries to parse
request.GET.getlist('filter')as integers. If any value fails integer conversion, it setsids = None, but then stores the fallback queryset intransfersinstead oflineitems. A few lines later, the code always iterates overlineitems, which is undefined in that branch.This means a bad
filtervalue can trigger an exception instead of rendering the printable.Evidence
Relevant code:
esp/esp/program/modules/handlers/programprintables.pyCurrent control flow in
paid_list():request.GET.getlist('filter')ValueError, set:ids = Nonesingle_select = Falseids is Nonebranch assign:transfers = ...for lineitem in lineitems:Because
lineitemsis not assigned in that fallback branch, the function can raise an exception before rendering.Steps to Reproduce
esp/esp/program/modules/handlers/programprintables.py.paid_list().'filter' in request.GETValueErrortransfers, notlineitems.lineitemsunconditionally.A request like this should hit the bad path:
...?filter=abcExpected Behavior
If
filtercontains an invalid value, the handler should either:It should not crash.
Actual Behavior
An invalid
filtervalue can leavelineitemsundefined and cause the handler to fail before rendering the page.Impact
This is a real crash path in an admin printable workflow. It can be triggered by malformed query parameters, stale links, or manual URL edits.
Suggested Fix
In the invalid-filter fallback branch, assign the queryset to
lineitemsinstead oftransfers, or otherwise normalize the branches so the later code always works with the same variable.Additional Context
Verified against current
mainby inspectingpaid_list()in:esp/esp/program/modules/handlers/programprintables.py