diff --git a/backend/SearchEpc.py b/backend/SearchEpc.py index e5bd28da..a633176e 100644 --- a/backend/SearchEpc.py +++ b/backend/SearchEpc.py @@ -551,7 +551,15 @@ class SearchEpc: # Take the uprn from the most recent uprns = {newest_epc["uprn"]} else: - raise ValueError("Multiple UPRNs found - investigate me") + # We check if we have UPRNs that match the one we're given and if so, filter on those + if self.uprn is not None: + uprns = {u for u in uprns if int(u) == self.uprn} + if len(uprns) == 1: + logger.info( + f"Multiple UPRNs found but one matches provided UPRN {self.uprn}, using this UPRN" + ) + else: + raise ValueError("Multiple UPRNs found - investigate me") # if uprns: # epc_uprn = uprns.pop()