diff --git a/frappe/core/page/dashboard/dashboard.py b/frappe/core/page/dashboard/dashboard.py index 5c3428738f..635ae7c990 100644 --- a/frappe/core/page/dashboard/dashboard.py +++ b/frappe/core/page/dashboard/dashboard.py @@ -30,15 +30,29 @@ def cache_source(function): return wrapper def generate_and_cache_results(args, function, cache_key): - args = frappe._dict(args) - results = function( - chart_name = args.chart_name, - filters = args.filters or None, - from_date = args.from_date or None, - to_date = args.to_date or None, - time_interval = args.time_interval or None, - timespan = args.timespan or None, - ) + try: + args = frappe._dict(args) + results = function( + chart_name = args.chart_name, + filters = args.filters or None, + from_date = args.from_date or None, + to_date = args.to_date or None, + time_interval = args.time_interval or None, + timespan = args.timespan or None, + ) + except TypeError as e: + if e.message == "'NoneType' object is not iterable": + # Probably because of invalid link filter + # + # Note: Do not try to find the right way of doing this because + # it results in an inelegant & inefficient solution + # ref: https://github.com/frappe/frappe/pull/9403 + frappe.throw(_('Please check the filter values set for Dashboard Chart: {}').format( + get_link_to_form(chart.doctype, chart.name)), title=_('Invalid Filter Value')) + return + else: + raise + frappe.cache().set_value(cache_key, json.dumps(results, default=str)) frappe.db.set_value("Dashboard Chart", args.chart_name, "last_synced_on", frappe.utils.now(), update_modified = False) return results