You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Answer 500, not 503, when a household job's create may have been committed #1089
POST /household-calculations creates the household job in one transaction: it inserts the household_jobs row and commits. HouseholdJobStore.create_job lets every SQLAlchemyError through unchanged, and HouseholdCalculationService._create answers each with 503 database_unavailable (logged as household_job_not_created).
When the connection fails during the commit, PostgreSQL may already have applied it, so the job may exist. The Public API reads sim's coded 503 as "no job of the submission will run" and tells its caller so. A resubmission then creates a second job.
What should happen
Do what the economy and household report routes already do (#1052): when the commit fails after the job's row was inserted, answer the JSON 500 internal_error, which the Public API reads as "the job may exist", start no Modal call, and log the failure with the commit error's type. Answer 503 database_unavailable only when nothing was written. A refused reference stays 400 missing_reference, and a normal submission is unchanged.
The Public API needs no change: its household adapter (policyengine_api/libs/simulation_household_calculations.py) already reads sim's 500 as a job that may exist.
Activity