From 5710e2eb01db8e1212566351fd2672e3002aa088 Mon Sep 17 00:00:00 2001 From: Buxdehuda Date: Mon, 5 Feb 2024 18:12:42 +0100 Subject: [PATCH] add null check --- certbotstratoapi.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/certbotstratoapi.py b/certbotstratoapi.py index 695b03c..cbf9e22 100644 --- a/certbotstratoapi.py +++ b/certbotstratoapi.py @@ -154,12 +154,13 @@ def get_package_id(self) -> None: return else: # Old page layout: still relevant? - customer_link = package_element.find_next('a', class_='customer-link')['href'] - query_parameters = urllib.parse.parse_qs(customer_link) - if 'cID' in query_parameters: - self.package_id = query_parameters['cID'][0] - print(f'INFO: strato package id (cID): {self.package_id}') - return + customer_link = package_element.find_next('a', class_='customer-link') + if customer_link is not None and customer_link.has_attr('href'): + query_parameters = urllib.parse.parse_qs(customer_link['href']) + if 'cID' in query_parameters: + self.package_id = query_parameters['cID'][0] + print(f'INFO: strato package id (cID): {self.package_id}') + return print(f'ERROR: Domain {self.second_level_domain_name} not ' 'found in strato packages. Using fallback cID=1')