From 369485058bfdff993ef053591a5d05c0d4651101 Mon Sep 17 00:00:00 2001 From: Jun-te Kim Date: Tue, 7 Jul 2026 10:38:28 +0000 Subject: [PATCH] fix(building-passport): handle properties with no UPRN Opening the building passport of an unmatched property 500'd: the whole page is UPRN-keyed and getSpatialData did BigInt(propertyMeta.uprn) with a null uprn ("Cannot convert null to a BigInt"). Since a property with no UPRN has no spatial data, installed measures, or EPC to show, render a clear "not matched yet" state with a link back to the portfolio instead of crashing. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../building-passport/[propertyId]/page.tsx | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/app/portfolio/[slug]/building-passport/[propertyId]/page.tsx b/src/app/portfolio/[slug]/building-passport/[propertyId]/page.tsx index 92c12eed..ed2080be 100644 --- a/src/app/portfolio/[slug]/building-passport/[propertyId]/page.tsx +++ b/src/app/portfolio/[slug]/building-passport/[propertyId]/page.tsx @@ -6,8 +6,10 @@ import { SparklesIcon, BuildingOfficeIcon, ShieldCheckIcon, + ExclamationTriangleIcon, } from "@heroicons/react/24/outline"; import { CheckCircleIcon, XCircleIcon } from "@heroicons/react/24/solid"; +import Link from "next/link"; import { getPropertyMeta, getConditionReport, @@ -67,6 +69,43 @@ export default async function BuildingPassportHome(props: { }) { const params = await props.params; const propertyMeta = await getPropertyMeta(params.propertyId); + + // A property with no UPRN isn't matched to an Ordnance Survey address yet, so + // the whole UPRN-keyed passport (spatial data, installed measures, EPC) has + // nothing to show — and getSpatialData(BigInt(null)) would 500. Surface a + // clear "not matched" state and link back to the portfolio instead. + if (!propertyMeta.uprn) { + return ( +
+
+ +

+ Not matched to a UPRN yet +

+

+ {propertyMeta.address ? ( + <> + {propertyMeta.address}{" "} + hasn't{" "} + + ) : ( + "This property hasn't " + )} + been matched to an Ordnance Survey address, so its building passport + isn't available yet. Match it to a UPRN from the portfolio to + unlock the passport. +

+ + Back to portfolio + +
+
+ ); + } + const conditionReport = await getConditionReport(params.propertyId); const spatial = await getSpatialData(propertyMeta.uprn); const installedMeasures = await getInstalledMeasuresByUprn(Number(propertyMeta.uprn));