Skip to content

Bug: Reports marked as complete with empty output cause crash #581

@SakshiKekre

Description

@SakshiKekre

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions