Error on latest update

In the latest update we are getting the following error

Traceback (most recent call last):
File “/usr/lib/python2.7/”, line 174, in _run_module_as_main
main”, fname, loader, pkg_name)
File “/usr/lib/python2.7/”, line 72, in _run_code
exec code in run_globals
File “/home/erp_healthcare/frappe-bench/apps/frappe/frappe/utils/”, line 97, in
File “/home/erp_healthcare/frappe-bench/apps/frappe/frappe/utils/”, line 18, in main
File “/home/erp_healthcare/frappe-bench/env/local/lib/python2.7/site-packages/click/”, line 722, in call
return self.main(*args, **kwargs)
File “/home/erp_healthcare/frappe-bench/env/local/lib/python2.7/site-packages/click/”, line 697, in main
rv = self.invoke(ctx)
File “/home/erp_healthcare/frappe-bench/env/local/lib/python2.7/site-packages/click/”, line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/erp_healthcare/frappe-bench/env/local/lib/python2.7/site-packages/click/”, line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/erp_healthcare/frappe-bench/env/local/lib/python2.7/site-packages/click/”, line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/home/erp_healthcare/frappe-bench/env/local/lib/python2.7/site-packages/click/”, line 535, in invoke
return callback(*args, **kwargs)
File “/home/erp_healthcare/frappe-bench/env/local/lib/python2.7/site-packages/click/”, line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File “/home/erp_healthcare/frappe-bench/apps/frappe/frappe/commands/”, line 25, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
File “/home/erp_healthcare/frappe-bench/apps/frappe/frappe/commands/”, line 222, in migrate
migrate(context.verbose, rebuild_website=rebuild_website)
File “/home/erp_healthcare/frappe-bench/apps/frappe/frappe/”, line 39, in migrate
File “/home/erp_healthcare/frappe-bench/apps/frappe/frappe/modules/”, line 29, in run_all
if not run_single(patchmodule = patch):
File “/home/erp_healthcare/frappe-bench/apps/frappe/frappe/modules/”, line 63, in run_single
return execute_patch(patchmodule, method, methodargs)
File “/home/erp_healthcare/frappe-bench/apps/frappe/frappe/modules/”, line 83, in execute_patch
frappe.get_attr(patchmodule.split()[0] + “.execute”)()
File “/home/erp_healthcare/frappe-bench/apps/frappe/frappe/patches/v11_0/”, line 22, in execute
order_by = order_by.replace(‘`’, ‘’).split(‘.’)[1]
IndexError: list index out of range

The value of order_by is modified desc


Worked for me fine. Tried it on different backups. Can you tell me what was the value of order_by prior to replace and split ?

Ideally, order_by should be something like `tabDocType`.`modified` desc
Replace should yield tabDocType.modified desc and split should do ['tabDocType', 'modified desc']

@Zlash65 I checked on my local install also. It failed there as well for the older sites. For a new site it worked without an issue.


I checked the database. What it seems if there is a doctype where orderby is not set, then it shows :
“order_by”: “modified desc” otherwise it is defined as “order_by”: “<<doctype>>.modified desc” .

Can you kindly check.


What version are you on ?

Can you share a screenshot of how order_by is looking like in your database ?
Maybe older version had a different way of storing it that wasn’t accounted for.

Facing same issue here.

Here is the output of SELECT * FROM `__UserSettings`;

***************************[ 1. row ]***************************
user    | Administrator
doctype | Membership
data    | {"updated_on": "Fri May 04 2018 11:30:16 GMT+0530", "List": {"sort_order": "desc", "filters": [], "sort_by": "modified"}, "last_view": "List"}
***************************[ 2. row ]***************************
user    |
doctype | Domain Settings
data    | {}
***************************[ 3. row ]***************************
user    |
doctype | Membership
data    | {"updated_on": "Fri May 04 2018 11:30:16 GMT+0530", "last_view": "List", "List": {"order_by": "`tabMembership`.`modified` desc", "filters": []}}

suggested change
if (not order_by.startswith(“tab"+d['doctype']+"”) ) :
order_by = “tab"+d['doctype']+"”+“.modified desc”

Thats a sort of fix too, but its more like hardcoding modified desc.

order_by can be based on name, title, etc kinds of field so this wouldn’t work for most.

Here’s a potential fix for it that accounts for older order_by or an empty order_by -


@Zlash65 Thanks for the update. Appreciate you quick solution.