Error upgrading to Plone 6.0.x

I'm upgrading our website from 5.2.x to 6.0.x and after replacing the version pins and running buildout, the website starts, but any page breaks with the following traceback:

2024-02-02 19:27:29,640 ERROR   [waitress:435][waitress-0] Exception while serving /website/@@plone-upgrade
Traceback (most recent call last):
  File "/srv/s-derfreitag/.batou-shared-eggs/Zope-5.8.5-py3.11.egg/ZPublisher/WSGIPublisher.py", line 181, in transaction_pubevents
    yield
  File "/srv/s-derfreitag/.batou-shared-eggs/Zope-5.8.5-py3.11.egg/ZPublisher/WSGIPublisher.py", line 391, in publish_module
    response = _publish(request, new_mod_info)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/s-derfreitag/.batou-shared-eggs/Zope-5.8.5-py3.11.egg/ZPublisher/WSGIPublisher.py", line 269, in publish
    obj = request.traverse(path, validated_hook=validate_user)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/s-derfreitag/.batou-shared-eggs/Zope-5.8.5-py3.11.egg/ZPublisher/BaseRequest.py", line 446, in traverse
    bpth(object, self)
  File "/srv/s-derfreitag/.batou-shared-eggs/Zope-5.8.5-py3.11.egg/ZPublisher/BeforeTraverse.py", line 104, in __call__
    getattr(container.__class__, self._hookname)(container,
  File "/srv/s-derfreitag/.batou-shared-eggs/Products.CMFPlone-6.0.7.post0-py3.11.egg/Products/CMFPlone/Portal.py", line 136, in __before_publishing_traverse__
    notify(BeforeTraverseEvent(self, REQUEST))
  File "/srv/s-derfreitag/.batou-shared-eggs/zope.event-5.0-py3.11.egg/zope/event/__init__.py", line 33, in notify
    subscriber(event)
  File "/srv/s-derfreitag/.batou-shared-eggs/zope.component-6.0-py3.11.egg/zope/component/event.py", line 27, in dispatch
    component_subscribers(event, None)
  File "/srv/s-derfreitag/.batou-shared-eggs/zope.component-6.0-py3.11.egg/zope/component/_api.py", line 146, in subscribers
    return sitemanager.subscribers(objects, interface)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/s-derfreitag/.batou-shared-eggs/zope.interface-6.0-py3.11-linux-x86_64.egg/zope/interface/registry.py", line 445, in subscribers
    return self.adapters.subscribers(objects, provided)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/s-derfreitag/.batou-shared-eggs/zope.interface-6.0-py3.11-linux-x86_64.egg/zope/interface/adapter.py", line 896, in subscribers
    subscription(*objects)
  File "/srv/s-derfreitag/.batou-shared-eggs/zope.component-6.0-py3.11.egg/zope/component/event.py", line 37, in objectEventNotify
    component_subscribers((event.object, event), None)
  File "/srv/s-derfreitag/.batou-shared-eggs/zope.component-6.0-py3.11.egg/zope/component/_api.py", line 146, in subscribers
    return sitemanager.subscribers(objects, interface)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/s-derfreitag/.batou-shared-eggs/zope.interface-6.0-py3.11-linux-x86_64.egg/zope/interface/registry.py", line 445, in subscribers
    return self.adapters.subscribers(objects, provided)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/s-derfreitag/.batou-shared-eggs/zope.interface-6.0-py3.11-linux-x86_64.egg/zope/interface/adapter.py", line 892, in subscribers
    subscriptions = self.subscriptions([providedBy(o) for o in objects], provided)
                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/s-derfreitag/.batou-shared-eggs/zope.interface-6.0-py3.11-linux-x86_64.egg/zope/interface/adapter.py", line 892, in <listcomp>
    subscriptions = self.subscriptions([providedBy(o) for o in objects], provided)
                                        ^^^^^^^^^^^^^
  File "/srv/s-derfreitag/.batou-shared-eggs/plone.dexterity-3.0.3.post0-py3.11.egg/plone/dexterity/content.py", line 135, in __get__
    cache = getattr(inst, "_v__providedBy__", None)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/s-derfreitag/.batou-shared-eggs/Products.CMFPlone-6.0.7.post0-py3.11.egg/Products/CMFPlone/Portal.py", line 61, in __getattr__
    return super().__getattr__(name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/s-derfreitag/.batou-shared-eggs/Products.BTreeFolder2-5.1-py3.11.egg/Products/BTreeFolder2/BTreeFolder2.py", line 238, in __getattr__
    return self._tree[name]
           ~~~~~~~~~~^^^^^^
TypeError: 'NoneType' object is not subscriptable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/srv/s-derfreitag/.batou-shared-eggs/waitress-2.1.2-py3.11.egg/waitress/channel.py", line 428, in service
    task.service()
  File "/srv/s-derfreitag/.batou-shared-eggs/waitress-2.1.2-py3.11.egg/waitress/task.py", line 168, in service
    self.execute()
  File "/srv/s-derfreitag/.batou-shared-eggs/waitress-2.1.2-py3.11.egg/waitress/task.py", line 434, in execute
    app_iter = self.channel.server.application(environ, start_response)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/s-derfreitag/.batou-shared-eggs/Paste-3.5.3-py3.11.egg/paste/translogger.py", line 69, in __call__
    return self.application(environ, replacement_start_response)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/s-derfreitag/.batou-shared-eggs/Zope-5.8.5-py3.11.egg/ZPublisher/httpexceptions.py", line 30, in __call__
    return self.application(environ, start_response)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/s-derfreitag/.batou-shared-eggs/Zope-5.8.5-py3.11.egg/ZPublisher/WSGIPublisher.py", line 389, in publish_module
    with transaction_pubevents(request, response):
  File "/srv/s-derfreitag/.nix-profile/lib/python3.11/contextlib.py", line 155, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/srv/s-derfreitag/.batou-shared-eggs/Zope-5.8.5-py3.11.egg/ZPublisher/WSGIPublisher.py", line 235, in transaction_pubevents
    notify(pubevents.PubFailure(request, exc_info, retry))
  File "/srv/s-derfreitag/.batou-shared-eggs/zope.event-5.0-py3.11.egg/zope/event/__init__.py", line 33, in notify
    subscriber(event)
  File "/srv/s-derfreitag/.batou-shared-eggs/zope.component-6.0-py3.11.egg/zope/component/event.py", line 27, in dispatch
    component_subscribers(event, None)
  File "/srv/s-derfreitag/.batou-shared-eggs/zope.component-6.0-py3.11.egg/zope/component/_api.py", line 146, in subscribers
    return sitemanager.subscribers(objects, interface)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/s-derfreitag/.batou-shared-eggs/zope.interface-6.0-py3.11-linux-x86_64.egg/zope/interface/registry.py", line 445, in subscribers
    return self.adapters.subscribers(objects, provided)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/s-derfreitag/.batou-shared-eggs/zope.interface-6.0-py3.11-linux-x86_64.egg/zope/interface/adapter.py", line 896, in subscribers
    subscription(*objects)
  File "/srv/s-derfreitag/.batou-shared-eggs/Products.SiteErrorLog-6.0-py3.11.egg/Products/SiteErrorLog/SiteErrorLog.py", line 342, in IPubFailureSubscriber
    published = getattr(published, '__self__', published)  # method --> object
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/s-derfreitag/.batou-shared-eggs/Products.CMFPlone-6.0.7.post0-py3.11.egg/Products/CMFPlone/Portal.py", line 61, in __getattr__
    return super().__getattr__(name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/s-derfreitag/.batou-shared-eggs/Products.BTreeFolder2-5.1-py3.11.egg/Products/BTreeFolder2/BTreeFolder2.py", line 238, in __getattr__
    return self._tree[name]
           ~~~~~~~~~~^^^^^^
TypeError: 'NoneType' object is not subscriptable

On the upgrade guide it is mentioned that the site should be blank, but running the @@plone-upgrade should fix it, but again, I'm getting the same error trying to reach that view :confused:

Any ideas? :thinking: :pray:t4:

So, after a bit of debugging, no wonder, this is a problem in our custom code :blush: :sweat_smile: