From d7a648f7bfdaef01966df378fff2dc17ffefb842 Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Wed, 12 Aug 2020 15:49:48 +0530 Subject: [PATCH] fix: Show message for invalid _sidebar.json --- frappe/website/context.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/frappe/website/context.py b/frappe/website/context.py index c5f23ab21c..335d0c0643 100644 --- a/frappe/website/context.py +++ b/frappe/website/context.py @@ -129,8 +129,12 @@ def build_context(context): def load_sidebar(context, sidebar_json_path): with open(sidebar_json_path, 'r') as sidebarfile: - context.sidebar_items = json.loads(sidebarfile.read()) - context.show_sidebar = 1 + try: + sidebar_json = sidebarfile.read() + context.sidebar_items = json.loads(sidebar_json) + context.show_sidebar = 1 + except json.decoder.JSONDecodeError: + frappe.throw('Invalid Sidebar JSON at ' + sidebar_json_path) def get_sidebar_json_path(path, look_for=False): '''