-
Notifications
You must be signed in to change notification settings - Fork 26
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Bug
TaxBenefitSystem.clone() followed by parameter.update() breaks ParameterNodeAtInstant.__iter__ for directory-based ParameterNodes. This causes silent calculation failures when the API applies reforms.
Reproduction
The bug manifests in the API's reform path (country.py):
system = self.tax_benefit_system.clone()
for parameter_name in reform:
parameter = get_parameter(system.parameters, parameter_name)
parameter.update(start=..., stop=..., value=...)
# Later, a formula iterates a ParameterNode:
cats = p.loss_eligible_categories # directory-based ParameterNode
for cat in cats: # fails after clone() + update()
total += max_(add(person, period, cats[cat]), 0)Cannot reproduce locally with Reform.from_dict() or even with manual clone() + update() — the failure is specific to the deployed API environment. The exact mechanism is unclear.
Impact
- NJ state tax calculations silently returned null for all reform scenarios (fixed in Fix NJ gross income formula that breaks API reform calculations policyengine-us#7743 by replacing iteration with explicit attribute access)
- Any formula iterating a directory-based ParameterNode would be affected under reforms
- Combined with silent exception swallowing in the API (clone()-based reform path breaks ParameterNode iteration, silently fails for NJ policyengine-api#3322, fix in Log exceptions instead of silently swallowing them in calculate policyengine-api#3323), this was invisible in production
Expected behavior
ParameterNodeAtInstant.__iter__ should work correctly after clone() + parameter.update(), the same as it does with Reform.from_dict().
Context
- API version: 1.592.4
- Only directory-based ParameterNodes are affected (not
unit: listparameter files) Reform.from_dict()works fine — only the clone path breaks
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working