PolicyEngine / PolicyEngine/policyengine-app-v2

Bug: Reports marked as complete with empty output cause crash

Open
#581 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
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:

  1. Mark report as status: "error" when calculation fails
  2. Store error message in report metadata
  3. 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 in SocietyWideReportOutput.tsx
  • Add early returns in components that access nested output properties
  • Show error page instead of crashing when output is incomplete

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.