Getting an error on Loading the Item page on Develop Branch


I am getting the below error for some javascript error on my test account which is on develop branch updated to the below commits:

ERPNext: v8.x.x-beta (e09b507) (develop)

Frappe Framework: v8.x.x-beta (11da197) (develop)

Now the moment I open the item page I am getting the below error in the console.

form.min.js:4995 Uncaught TypeError: Cannot read property 'refresh' of undefined
    at Object.frappe.ui.form.set_viewers (form.min.js:4995)
    at n.<anonymous> (form.min.js:88)
    at n.emit (libs.min.js:8007)
    at n.onevent (libs.min.js:8008)
    at n.onpacket (libs.min.js:8008)
    at n.<anonymous> (libs.min.js:8008)
    at n.emit (libs.min.js:8007)
    at n.ondecoded (libs.min.js:8007)
    at s.<anonymous> (libs.min.js:8008)
    at s.n.emit (libs.min.js:8007)
frappe.ui.form.set_viewers @ form.min.js:4995
(anonymous) @ form.min.js:88
n.emit @ libs.min.js:8007
n.onevent @ libs.min.js:8008
n.onpacket @ libs.min.js:8008
(anonymous) @ libs.min.js:8008
n.emit @ libs.min.js:8007
n.ondecoded @ libs.min.js:8007
(anonymous) @ libs.min.js:8008
n.emit @ libs.min.js:8007
s.add @ libs.min.js:8007
n.ondata @ libs.min.js:8007
(anonymous) @ libs.min.js:8008
n.emit @ libs.min.js:8007
n.onPacket @ libs.min.js:8007
(anonymous) @ libs.min.js:8007
n.emit @ libs.min.js:8007
n.onPacket @ libs.min.js:8008
n.onData @ libs.min.js:8008
ws.onmessage @ libs.min.js:8008

I do have some custom javascript running on the item page but I haven’t changed anything in that code since a long time so I am assuming that this error is due to the recent updated in the framework, do I need to change some of my customizations or is this a bug?

Turns out this is error is common across the board and means its a frappe issue. I found the reason, I had skipped the patch frappe.patches.v8_x.update_user_permission while updating.

Would like to inform that the team that this patch is taking an eternity to execute on my local system since my DB returned 8085 values on running the query:

select name, parent, defkey, defvalue 
from tabDefaultValue 
where parent not in ('__default', '__global') and substr(defkey,1,1)!='_' and parenttype='User Permission';

Which the above patch is using so is it normal for this patch to take an hour or so?

1 Like

There is a bug in that script, team will push a fix, I think tomorrow

Well I have just discovered that this patch fails on my system after running for 30~45 mins with the below validation error:

Executing frappe.patches.v8_x.update_user_permission in local-rigpl (rigpl)
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/aditya/frappe-bench/apps/frappe/frappe/utils/", line 91, in <module>
  File "/home/aditya/frappe-bench/apps/frappe/frappe/utils/", line 17, in main
  File "/home/aditya/frappe-bench/env/local/lib/python2.7/site-packages/click/", line 716, in __call__
    return self.main(*args, **kwargs)
  File "/home/aditya/frappe-bench/env/local/lib/python2.7/site-packages/click/", line 696, in main
    rv = self.invoke(ctx)
  File "/home/aditya/frappe-bench/env/local/lib/python2.7/site-packages/click/", line 1060, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/aditya/frappe-bench/env/local/lib/python2.7/site-packages/click/", line 1060, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/aditya/frappe-bench/env/local/lib/python2.7/site-packages/click/", line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/aditya/frappe-bench/env/local/lib/python2.7/site-packages/click/", line 534, in invoke
    return callback(*args, **kwargs)
  File "/home/aditya/frappe-bench/env/local/lib/python2.7/site-packages/click/", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/aditya/frappe-bench/apps/frappe/frappe/commands/", line 24, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
  File "/home/aditya/frappe-bench/apps/frappe/frappe/commands/", line 216, in migrate
    migrate(context.verbose, rebuild_website=rebuild_website)
  File "/home/aditya/frappe-bench/apps/frappe/frappe/", line 31, in migrate
  File "/home/aditya/frappe-bench/apps/frappe/frappe/modules/", line 29, in run_all
    if not run_single(patchmodule = patch):
  File "/home/aditya/frappe-bench/apps/frappe/frappe/modules/", line 63, in run_single
    return execute_patch(patchmodule, method, methodargs)
  File "/home/aditya/frappe-bench/apps/frappe/frappe/modules/", line 83, in execute_patch
    frappe.get_attr(patchmodule.split()[0] + ".execute")()
  File "/home/aditya/frappe-bench/apps/frappe/frappe/patches/v8_x/", line 23, in execute
    )).insert(ignore_permissions = True)
  File "/home/aditya/frappe-bench/apps/frappe/frappe/model/", line 219, in insert
  File "/home/aditya/frappe-bench/apps/frappe/frappe/model/", line 790, in run_post_save_methods
  File "/home/aditya/frappe-bench/apps/frappe/frappe/model/", line 666, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "/home/aditya/frappe-bench/apps/frappe/frappe/model/", line 887, in composer
    return composed(self, method, *args, **kwargs)
  File "/home/aditya/frappe-bench/apps/frappe/frappe/model/", line 870, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "/home/aditya/frappe-bench/apps/frappe/frappe/model/", line 660, in <lambda>
    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
  File "/home/aditya/frappe-bench/apps/frappe/frappe/core/doctype/user_permission/", line 16, in on_update
  File "/home/aditya/frappe-bench/apps/frappe/frappe/core/doctype/user_permission/", line 39, in apply_user_permissions_to_all_roles
    'apply_user_permissions', '1')
  File "/home/aditya/frappe-bench/apps/frappe/frappe/", line 488, in update_permission_property
  File "/home/aditya/frappe-bench/apps/frappe/frappe/core/doctype/doctype/", line 628, in validate_permissions_for_doctype
    validate_permissions(doctype, for_remove)
  File "/home/aditya/frappe-bench/apps/frappe/frappe/core/doctype/doctype/", line 740, in validate_permissions
  File "/home/aditya/frappe-bench/apps/frappe/frappe/core/doctype/doctype/", line 681, in check_double
    .format(get_txt(d),	similar_because_of))
  File "/home/aditya/frappe-bench/apps/frappe/frappe/", line 319, in throw
    msgprint(msg, raise_exception=exc, title=title, indicator='red')
  File "/home/aditya/frappe-bench/apps/frappe/frappe/", line 309, in msgprint
  File "/home/aditya/frappe-bench/apps/frappe/frappe/", line 282, in _raise_exception
    raise raise_exception(encode(msg))
frappe.exceptions.ValidationError: For System Manager at level 0 in Global Defaults in row 1: Only one rule allowed with the same Role, Level and Apply User Permissions

@adityaduggal this patch should not take so long. @makarand_b will release an update tomorrow.