Skip to content

Fix: Guard domestic hot water mapping against undefined lists - #97

Open
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/dhw-mapping-undefined-lists
Open

sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/dhw-mapping-undefined-lists

Conversation

@sentry

@sentry sentry Bot commented Oct 3, 2026

Copy link
Copy Markdown

This PR addresses a TypeError (Cannot read properties of undefined (reading '0')) occurring in mapHotWaterSourcesData when the waterStorage section of the domestic hot water state is incomplete.

The root cause was that resolveState omits sections that are not marked as complete, leading to state.domesticHotWater.waterStorage being undefined. The code then attempted to access waterStorage[0] without optional chaining, causing the crash.

Changes made in mapping/domesticHotWaterMapper.ts:

  • Changed state.domesticHotWater.waterStorage[0] to state.domesticHotWater.waterStorage?.[0] to safely handle undefined values.
  • Added ?? [] guards to state.domesticHotWater.pipework and state.domesticHotWater.hotWaterOutlets when calling .filter() to prevent similar TypeErrors if these lists are undefined.

Fixes EPB-CHECK-PART-L-FRONTEND-1B

@sentry <feedback>: Autofix iterates on these changes
@sentry stop iterating: Autofix stops iterating on this run

This PR was automatically generated by Sentry at no cost. You can adjust this setting at any time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants