plone / Products.CMFPlone

The core of the Plone content management system
https://plone.org
GNU General Public License v2.0
240 stars 183 forks source link

TypeError thrown when during groups lookup #3952

Closed alecpm closed 3 weeks ago

alecpm commented 1 month ago

The offending code is here. The traceback looks like this:

Traceback (innermost last):
  Module ZPublisher.WSGIPublisher, line 176, in transaction_pubevents
  Module ZPublisher.WSGIPublisher, line 385, in publish_module
  Module ZPublisher.WSGIPublisher, line 280, in publish
  Module ZPublisher.mapply, line 85, in mapply
  Module ZPublisher.WSGIPublisher, line 63, in call_object
  Module Products.CMFPlone.controlpanel.browser.usergroups_usermembership, line 57, in __call__
  Module Products.CMFPlone.controlpanel.browser.usergroups_usermembership, line 54, in update
  Module Products.CMFPlone.controlpanel.browser.usergroups_usermembership, line 63, in getGroups
TypeError: '<' not supported between instances of 'bool' and 'str'

The issue is that when there's a None value in the groupResults (which is anticipated in the sort code) the lambda returns False which fails to compare against the group title/name strings under Python 3. The list comprehension that defines groupResults should probably just filter out None values to avoid this issue. I'm not entirely sure what circumstances result in a None group value, but I am seeing it occur in a real world use case.

davisagli commented 1 month ago

FWIW we fixed a similar bug in plone.restapi recently: https://github.com/plone/plone.restapi/pull/1775

I think it can happen if a group is enumerated by a PAS plugin but it can't actually be fetched by id for some reason.

In your case maybe there is something wrong with what the dexterity.membrane PAS plugins are returning?