User Administrator Cannot be Disabled

Hi,
While updating the bench I am getting the below error. Any idea how to get rid-off this issue?

File “/usr/lib/python2.7/runpy.py”, line 162, in _run_module_as_main
“main”, fname, loader, pkg_name)
File “/usr/lib/python2.7/runpy.py”, line 72, in _run_code
exec code in run_globals
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 94, in
main()
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 18, in main
click.Group(commands=commands)(prog_name=‘bench’)
File “/home/ubuntu/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 664, in call
return self.main(*args, **kwargs)
File “/home/ubuntu/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 644, in main
rv = self.invoke(ctx)
File “/home/ubuntu/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 991, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/ubuntu/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 991, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/ubuntu/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 837, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/home/ubuntu/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 464, in invoke
return callback(*args, **kwargs)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/commands/init.py”, line 24, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/commands/site.py”, line 217, in migrate
migrate(context.verbose, rebuild_website=rebuild_website)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/migrate.py”, line 33, in migrate
frappe.model.sync.sync_all(verbose=verbose)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/sync.py”, line 19, in sync_all
sync_for(app, force, verbose=verbose, reset_permissions=reset_permissions)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/sync.py”, line 45, in sync_for
reset_permissions=reset_permissions, for_sync=True)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/modules/import_file.py”, line 58, in import_file_by_path
ignore_version=ignore_version, reset_permissions=reset_permissions)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/modules/import_file.py”, line 131, in import_doc
doc.insert()
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/document.py”, line 245, in insert
self.run_post_save_methods()
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/document.py”, line 827, in run_post_save_methods
self.run_method(“on_update”)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/document.py”, line 702, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/document.py”, line 924, in composer
return composed(self, method, *args, **kwargs)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/document.py”, line 907, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/document.py”, line 696, in
fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/core/doctype/doctype/doctype.py”, line 206, in on_update
make_module_and_roles(self)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/core/doctype/doctype/doctype.py”, line 783, in make_module_and_roles
r.insert()
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/document.py”, line 239, in insert
self.run_method(“after_insert”)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/document.py”, line 702, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/document.py”, line 924, in composer
return composed(self, method, *args, **kwargs)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/document.py”, line 907, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/document.py”, line 696, in
fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/core/doctype/role/role.py”, line 19, in after_insert
user.add_roles(self.name)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/core/doctype/user/user.py”, line 368, in add_roles
self.save()
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/document.py”, line 256, in save
return self._save(*args, **kwargs)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/document.py”, line 290, in save
self.run_before_save_methods()
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/document.py”, line 809, in run_before_save_methods
self.run_method(“validate”)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/document.py”, line 702, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/document.py”, line 924, in composer
return composed(self, method, *args, **kwargs)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/document.py”, line 907, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/document.py”, line 696, in
fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/core/doctype/user/user.py”, line 62, in validate
self.check_enable_disable()
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/core/doctype/user/user.py”, line 100, in check_enable_disable
frappe.throw((“User {0} cannot be disabled”).format(self.name))
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/init.py”, line 319, in throw
msgprint(msg, raise_exception=exc, title=title, indicator=‘red’)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/init.py”, line 309, in msgprint
_raise_exception()
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/init.py”, line 282, in _raise_exception
raise raise_exception(encode(msg))
frappe.exceptions.ValidationError: User Administrator cannot be disabled

Regards
Ruchin Sharma

What is the use case, where you want to disable the Administrator user.

Dear @saurabh6790
I just did a bench update after a long time may be after 4-6 months and I am getting the below error. I really don’t know what is the issue while updating bench.

I just ran

bench update 

Also tried

bench update --reset

Trace:
ubuntu@ip-10-0-1-207:~/frappe-bench$ bench update
INFO:bench.utils:updating bench
INFO:bench.utils:git pull
Already up-to-date.
INFO:bench.utils:./env/bin/pip install Pillow
Requirement already satisfied: Pillow in ./env/lib/python2.7/site-packages
INFO:bench.app:pulling frappe
INFO:bench.utils:git pull upstream master
From https://github.com/frappe/frappe

  • branch master -> FETCH_HEAD
    Already up-to-date.
    INFO:bench.utils:find . -name “*.pyc” -delete
    INFO:bench.app:pulling erpnext
    INFO:bench.utils:git pull upstream master
    From https://github.com/frappe/erpnext
  • branch master -> FETCH_HEAD
    Already up-to-date.
    INFO:bench.utils:find . -name “*.pyc” -delete
    Updating Python libraries…
    INFO:bench.utils:./env/bin/pip install --upgrade pip
    /home/ubuntu/frappe-bench/env/local/lib/python2.7/site-packages/pip/vendor/requests/packages/urllib3/util/ssl.py:318: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#snimissingwarning.
    SNIMissingWarning
    /home/ubuntu/frappe-bench/env/local/lib/python2.7/site-packages/pip/vendor/requests/packages/urllib3/util/ssl.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
    InsecurePlatformWarning
    Requirement already up-to-date: pip in ./env/lib/python2.7/site-packages
    INFO:bench.utils:./env/bin/pip install -q -r /home/ubuntu/bench-repo/requirements.txt
    INFO:bench.utils:./env/bin/pip install -q -r ./apps/frappe/requirements.txt
    INFO:bench.utils:./env/bin/pip install -q -r ./apps/erpnext/requirements.txt
    INFO:bench.utils:./env/bin/pip install -q -r ./apps/library/requirements.txt
    Updating node libraries…
    INFO:bench.utils:npm install
    npm WARN optional Skipping failed optional dependency /chokidar/fsevents:
    npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.1.2
    npm WARN frappe@ No description
    Backing up sites…
    Patching sites…
    Migrating library
    Updating DocTypes for frappe : [========================================]
    Syncing help database…
    Migrating site1.local
    Updating DocTypes for frappe : [========================================]
    Updating DocTypes for erpnext : [==================================== ]Traceback (most recent call last):
    File “/usr/lib/python2.7/runpy.py”, line 162, in _run_module_as_main
    main”, fname, loader, pkg_name)
    File “/usr/lib/python2.7/runpy.py”, line 72, in _run_code
    exec code in run_globals
    File “/home/ubuntu/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 94, in
    main()
    File “/home/ubuntu/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 18, in main
    click.Group(commands=commands)(prog_name=‘bench’)
    File “/home/ubuntu/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 664, in call
    return self.main(*args, **kwargs)
    File “/home/ubuntu/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 644, in main
    rv = self.invoke(ctx)
    File “/home/ubuntu/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 991, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
    File “/home/ubuntu/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 991, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
    File “/home/ubuntu/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 837, in invoke
    return ctx.invoke(self.callback, **ctx.params)
    File “/home/ubuntu/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 464, in invoke
    return callback(*args, **kwargs)
    File “/home/ubuntu/frappe-bench/apps/frappe/frappe/commands/init.py”, line 24, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
    File “/home/ubuntu/frappe-bench/apps/frappe/frappe/commands/site.py”, line 217, in migrate
    migrate(context.verbose, rebuild_website=rebuild_website)
    File “/home/ubuntu/frappe-bench/apps/frappe/frappe/migrate.py”, line 33, in migrate
    frappe.model.sync.sync_all(verbose=verbose)
    File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/sync.py”, line 19, in sync_all
    sync_for(app, force, verbose=verbose, reset_permissions=reset_permissions)
    File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/sync.py”, line 45, in sync_for
    reset_permissions=reset_permissions, for_sync=True)
    File “/home/ubuntu/frappe-bench/apps/frappe/frappe/modules/import_file.py”, line 58, in import_file_by_path
    ignore_version=ignore_version, reset_permissions=reset_permissions)
    File “/home/ubuntu/frappe-bench/apps/frappe/frappe/modules/import_file.py”, line 131, in import_doc
    doc.insert()
    File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/document.py”, line 245, in insert
    self.run_post_save_methods()
    File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/document.py”, line 827, in run_post_save_methods
    self.run_method(“on_update”)
    File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/document.py”, line 702, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
    File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/document.py”, line 924, in composer
    return composed(self, method, *args, **kwargs)
    File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/document.py”, line 907, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
    File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/document.py”, line 696, in
    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
    File “/home/ubuntu/frappe-bench/apps/frappe/frappe/core/doctype/doctype/doctype.py”, line 206, in on_update
    make_module_and_roles(self)
    File “/home/ubuntu/frappe-bench/apps/frappe/frappe/core/doctype/doctype/doctype.py”, line 783, in make_module_and_roles
    r.insert()
    File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/document.py”, line 239, in insert
    self.run_method(“after_insert”)
    File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/document.py”, line 702, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
    File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/document.py”, line 924, in composer
    return composed(self, method, *args, **kwargs)
    File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/document.py”, line 907, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
    File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/document.py”, line 696, in
    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
    File “/home/ubuntu/frappe-bench/apps/frappe/frappe/core/doctype/role/role.py”, line 19, in after_insert
    user.add_roles(self.name)
    File “/home/ubuntu/frappe-bench/apps/frappe/frappe/core/doctype/user/user.py”, line 368, in add_roles
    self.save()
    File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/document.py”, line 256, in save
    return self._save(*args, **kwargs)
    File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/document.py”, line 290, in save
    self.run_before_save_methods()
    File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/document.py”, line 809, in run_before_save_methods
    self.run_method(“validate”)
    File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/document.py”, line 702, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
    File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/document.py”, line 924, in composer
    return composed(self, method, *args, **kwargs)
    File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/document.py”, line 907, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
    File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/document.py”, line 696, in
    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
    File “/home/ubuntu/frappe-bench/apps/frappe/frappe/core/doctype/user/user.py”, line 62, in validate
    self.check_enable_disable()
    File “/home/ubuntu/frappe-bench/apps/frappe/frappe/core/doctype/user/user.py”, line 100, in check_enable_disable
    frappe.throw(
    (“User {0} cannot be disabled”).format(self.name))
    File “/home/ubuntu/frappe-bench/apps/frappe/frappe/init.py”, line 319, in throw
    msgprint(msg, raise_exception=exc, title=title, indicator=‘red’)
    File “/home/ubuntu/frappe-bench/apps/frappe/frappe/init.py”, line 309, in msgprint
    _raise_exception()
    File “/home/ubuntu/frappe-bench/apps/frappe/frappe/init.py”, line 282, in _raise_exception
    raise raise_exception(encode(msg))
    frappe.exceptions.ValidationError: User Administrator cannot be disabled
    ubuntu@ip-10-0-1-207:~/frappe-bench$

Regards
Ruchin Sharma

Does, anyone have any idea, how would I be able to recover my instance and update it back. Because it may happen with my live instance also, therefore I just did it on my test instance first.

Regards
Ruchin Sharma