frappe / lms

Easy to Use, 100% Open Source Learning Management System
https://frappe.io/learning
GNU Affero General Public License v3.0
1k stars 460 forks source link

Docker startup: Setup failed: Could not start up: Failed to update global settings #719

Open dlaufen opened 9 months ago

dlaufen commented 9 months ago

Describe the bug Initial start of the docker container I logged in with Administrator account and tried to finish the setup. On completion

To Reproduce Steps to reproduce the behavior:

  1. cd apps/lms/docker
  2. docker-compose up
  3. connect with Chrome to localhost:8000/#login
  4. Complete form: English (US), defaults for TZ(America/Adak) and Currency(USD)
  5. Press Complete Setup

Tried a few times with different settings by running the process again after 'docker-compose down --volumes'. No luck.

Expected behavior Expected it to accept my settings and let me continue.

Desktop (please complete the following information):

Additional context Error copied from browser:

App Versions

{
    "frappe": "16.0.0-dev",
    "lms": "1.0.0"
}

Route

setup-wizard/0

Traceback

Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 110, in application
    response = frappe.api.handle(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/api/__init__.py", line 49, in handle
    data = endpoint(**arguments)
           ^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/api/v1.py", line 36, in handle_rpc_call
    return frappe.handler.handle()
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/handler.py", line 49, in handle
    data = execute_cmd(cmd)
           ^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/handler.py", line 85, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/__init__.py", line 1711, in call
    return fn(*args, **newargs)
           ^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/utils/typing_validations.py", line 31, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/desk/page/setup_wizard/setup_wizard.py", line 64, in setup_complete
    return process_setup_stages(stages, args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/desk/page/setup_wizard/setup_wizard.py", line 84, in process_setup_stages
    task.get("fn")(task.get("args"))
  File "apps/frappe/frappe/desk/page/setup_wizard/setup_wizard.py", line 114, in update_global_settings
    create_or_update_user(args)
  File "apps/frappe/frappe/desk/page/setup_wizard/setup_wizard.py", line 224, in create_or_update_user
    user.insert()
  File "apps/frappe/frappe/model/document.py", line 281, in insert
    self.set_new_name(set_name=set_name, set_child_names=set_child_names)
  File "apps/frappe/frappe/model/document.py", line 478, in set_new_name
    set_new_name(self)
  File "apps/frappe/frappe/model/naming.py", line 163, in set_new_name
    doc.run_method("autoname")
  File "apps/frappe/frappe/model/document.py", line 954, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 1320, in composer
    return composed(self, method, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 1302, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
                              ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 951, in fn
    return method_object(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/core/doctype/user/user.py", line 126, in autoname
    self.email = self.email.strip().lower()
                 ^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'strip'

Request Data

{
    "type": "POST",
    "args": {
        "args": "{\"language\":\"English (United States)\",\"country\":\"United States\",\"timezone\":\"America/Adak\",\"currency\":\"USD\"}"
    },
    "headers": {},
    "error_handlers": {},
    "url": "/api/method/frappe.desk.page.setup_wizard.setup_wizard.setup_complete",
    "request_id": null
}

Response Data

{
    "setup_wizard_failure_message": "Failed to update global settings",
    "exception": "AttributeError: 'NoneType' object has no attribute 'strip'",
    "exc_type": "AttributeError"
}
dlaufen commented 9 months ago

follow up - I got the same behavior with a non-docker version of lms on a manually started bench.

Hacking around bit - After logging in as Administrator, I could point the manually reach the LMS app by pointing the browser to lms.localhost:8000/people or any other LMS app page. But still, on subsequent logins Frappe still wants to run the setup-wizard.

http://localhost:8000/app/setup-wizard/0

Also, I don't see how to add other users to the app, any pointers?

It seems from the error message detailed above, something is missing in the args for the frappe.session.user object when trying to form a default email for Administrator. Looking at frappe/cpre/doctype/user.py for some reason _self.get("isadmin") is not True. In the setup-wizard context, I am guessing "is_admin" should be True. If it were, it wouldn't be trying to strip a None email object.

I suspect there will be a simple fix... :)

Also is can someone point me to any documentation on how to setup a debug environment for lms? I'm using "baremetal" sort of, wsl2/ubuntu.

Thanks for any advice.