ModuleNotFoundError: frappe.types.frappedict

When running ERPnext with Frappe, I am getting on our deployment on kubernetes the error message

ModuleNotFoundError: No module named ‘frappe.types.frappedict’

erpnext 15.34.1
frappe 15.40.1

Server Log:

Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 99, in application
    init_request(request)
  File "apps/frappe/frappe/app.py", line 195, in init_request
    frappe.local.http_request = HTTPRequest()
                                ^^^^^^^^^^^^^
  File "apps/frappe/frappe/auth.py", line 43, in __init__
    self.set_session()
  File "apps/frappe/frappe/auth.py", line 77, in set_session
    frappe.local.login_manager = LoginManager()
                                 ^^^^^^^^^^^^^^
  File "apps/frappe/frappe/auth.py", line 119, in __init__
    self.make_session(resume=True)
  File "apps/frappe/frappe/auth.py", line 205, in make_session
    frappe.local.session_obj = Session(
                               ^^^^^^^^
  File "apps/frappe/frappe/sessions.py", line 214, in __init__
    self.resume()
  File "apps/frappe/frappe/sessions.py", line 290, in resume
    self.validate_user()
  File "apps/frappe/frappe/sessions.py", line 222, in validate_user
    if not frappe.get_cached_value("User", self.user, "enabled"):
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/__init__.py", line 1271, in get_cached_value
    doc = get_cached_doc(doctype, name)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/__init__.py", line 1210, in get_cached_doc
    if (key := can_cache_doc(args)) and (doc := cache.get_value(key)):
                                                ^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/utils/redis_wrapper.py", line 96, in get_value
    val = pickle.loads(val)
          ^^^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named 'frappe.types.frappedict'

ChatGPT says:

The error ModuleNotFoundError: No module named 'frappe.types.frappedict' typically indicates that the codebase is referencing an outdated or incorrect module path. In recent versions of Frappe, the module frappe.types.frappedict has been deprecated or its location has changed.

So how can I find out which module may cause that?

At all pods I did a bench build to be sure we have everything up-to-date.

Hello,

You can may be try

bench setup requirements && bench --site XXXX migrate && bench build --force && bench --site XXXX clear-cache && bench restart

1 Like

Thanks!

Did the trick. I will add this to the k8s deployment:


          lifecycle:
             postStart:
               exec:
                 command: ["/bin/sh", "-c", "sleep 60 && bench --site XXXX migrate && && bench build --force && bench --site XXXX clear-cache"]

If a pod is automatically being restarted or shifted to another worker, then it may get a newer image (as we always go for stable). I already did the migrate and the deployment worked fine for several months, but clearing cache seems to be necessary sometimes as well. BTW, within the docker image I can not do a bench setup requirements.