From af1ced7bc77b91cc2ae8f0cba219d9b62fadcac5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferenc=20G=C3=A9czi?= Date: Tue, 4 Jan 2022 00:00:00 +0000 Subject: [PATCH] carrier: dhl: Let's not index the dict with a potentially missing key The 'shipments' key might be still missing, because of any unexpected error. --- shipments/carrier.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shipments/carrier.py b/shipments/carrier.py index f5048e2..be8bb12 100644 --- a/shipments/carrier.py +++ b/shipments/carrier.py @@ -416,7 +416,7 @@ class DHL(Carrier): result.status_category = StatusCategory.ERROR result.tracking_url = 'https://www.dhl.com/gb-en/home/tracking/tracking-parcel.html?submit=1&tracking-id=' + code - if len(payload['shipments']): + if len(payload.get('shipments', '')): payload = payload['shipments'][0] else: result.status = payload[''] -- 2.45.2