PolicyEngine / PolicyEngine/policyengine-app-v2
Bug: Reports marked as complete with empty output cause crash
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 1
- Forks
- 3
- Avg merge
- 1d 50m
- Merged PRs (30d)
- 39
Description
Description
Some reports in the database are marked with status: "complete" but have an empty output ("{}"). When the app tries to render these reports, it crashes with:
Cannot read properties of undefined (reading 'budgetary_impact')
Root Cause
This is a server-side issue where calculations fail but reports are incorrectly marked as "complete" with an empty object instead of being marked as "error".
Affected Reports (Examples)
- Report 538:
status: "complete",output: "{}" - Report 539:
status: "complete",output: "{}"
Compared to working report:
- Report 530:
status: "complete",output: <64KB valid data>
Suggested Fixes
Server-side (Primary)
Investigate why the API/backend is marking failed calculations as "complete" with empty output. The proper behavior should be:
- Mark report as
status: "error"when calculation fails - Store error message in report metadata
- Never store empty
{}as output for complete reports
Client-side (Defensive)
Add validation guards to prevent crashes when encountering malformed data:
- Add
isValidSocietyWideOutput()type guard inSocietyWideReportOutput.tsx - Add early returns in components that access nested output properties
- Show error page instead of crashing when output is incomplete
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the crash using the malformed reports described in the issue, then inspect the server-side report status handling and SocietyWideReportOutput.tsx. Done means failed calculations are recorded as errors with metadata, complete reports do not contain empty output, and malformed output produces an error page instead of a crash.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- backend, frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100