From 318b47af3653036eb87988c39583edc1f72ed6dd Mon Sep 17 00:00:00 2001 From: Son NK <> Date: Tue, 21 Apr 2020 15:54:43 +0200 Subject: [PATCH] Handle the case invalid input for /api/apple/update_notification --- app/api/views/apple.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/api/views/apple.py b/app/api/views/apple.py index 851e4a48..4d21f2f4 100644 --- a/app/api/views/apple.py +++ b/app/api/views/apple.py @@ -220,6 +220,14 @@ def apple_update_notification(): # } LOG.debug("request for /api/apple/update_notification") data = request.get_json() + if not ( + data + and data.get("unified_receipt") + and data["unified_receipt"].get("latest_receipt_info") + ): + LOG.d("Invalid data %s", data) + return jsonify(error="Empty Response"), 400 + transactions = data["unified_receipt"]["latest_receipt_info"] # dict of original_transaction_id and transaction