diff --git a/domain/modelling/scoring/overlay_applicator.py b/domain/modelling/scoring/overlay_applicator.py index 961f4e02..6a50fde4 100644 --- a/domain/modelling/scoring/overlay_applicator.py +++ b/domain/modelling/scoring/overlay_applicator.py @@ -41,7 +41,13 @@ def apply_simulations( for simulation in simulations: for identifier, overlay in simulation.building_parts.items(): - part = parts_by_id[identifier] + # A Landlord Override can target a building part the lodged (or + # predicted) EPC never carried — e.g. an `extension_1` override on a + # property whose EPC has only `main`. Skip the orphaned part rather + # than crashing the whole property's modelling on a `KeyError`. + part = parts_by_id.get(identifier) + if part is None: + continue for overlay_field in fields(overlay): value = getattr(overlay, overlay_field.name) if value is not None: