Cannot delete a team with a purged mailing list

Bug #619022 reported by Curtis Hovey
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Launchpad itself
Fix Released
High
Unassigned

Bug Description

Why testing a fix for bug 610850, OOPS-1689EC2137 was encounter. It shows there is a new kind of oops:

  Module lp.registry.browser.peoplemerge, line 326, in merge_action
    self.context.setContactAddress(None)
  Module lp.registry.model.person, line 2052, in setContactAddress
    mailing_list_email = IMasterObject(mailing_list_email)
  Module zope.site.hooks, line 95, in adapter_hook
    return siteinfo.adapter_hook(interface, object, name, default)
  Module zope.security.adapter, line 88, in __call__
    adapter = self.factory(*args)
  Module canonical.launchpad.webapp.adapter, line 606, in get_object_from_master_store
    master_store = IMasterStore(obj)
TypeError: ('Could not adapt', None, <InterfaceClass canonical.launchpad.interfaces.lpstorm.IMasterStore>

The team had an mailing list. It was mark purged an hour before. I am surprised by this error:

        if self.mailing_list is not None:
            mailing_list_email = getUtility(IEmailAddressSet).getByEmail(
                self.mailing_list.address)
            mailing_list_email = IMasterObject(mailing_list_email)

I think the code may need to check if the mailing_list is purged to ensure it has an email address:
    if self.mailing_list is not None and self.mailing_list.status is not MailingListStatus.PURGED:

This code path is a few months old. I have not seen this oops before, but there re several teams with purged mailing lists that could experinece this if someone chooses to delete them.

We will know this issue is fixed when we can delete https://launchpad.net/~ubuntu-l10n-nds

Related branches

Revision history for this message
Curtis Hovey (sinzui) wrote :

This case is a little more esoteric. This team had a list purged, then it was renamed. The team has the old mailing list address but the mailing list does not. This is expected. setContactAddress should not assume that it will always have an email address for a mailing list. It is okay to be None, since the deletion loop does the right thing, but the MasterStore step is not needed.

Revision history for this message
Curtis Hovey (sinzui) wrote :

This is the test that allowed me to reproduce the oops based on the team's history.

class TestTeamContactAddress(TestCaseWithFactory):
    ...
    def test_setContactAddress_after_purged_mailing_list_and_rename(self):
        # This is the rare case where a list is purged for a team rename,
        # then the contact address is set/unset sometime afterwards.
        # The old mailing list address belongs the the team, but not the list.
        # 1. Create then purge a mailing list.
        list_address = self.createMailingListAndGetAddress()
        mailing_list = self.team.mailing_list
        mailing_list.deactivate()
        mailing_list.transitionToStatus(MailingListStatus.INACTIVE)
        mailing_list.purge()
        transaction.commit()
        # 2. Rename the team.
        login_celebrity('admin')
        self.team.name = 'beta'
        login_person(self.team.teamowner)
        # 3. Set the contact address.
        self.team.setContactAddress(None)
        self.assertEqual(None, self.team.preferredemail)
        self.assertEqual([], self.getAllEmailAddresses())

Revision history for this message
Curtis Hovey (sinzui) wrote :

Do we want to delete the mailing list address when the mailing list is set to the purged state? I think I do, but I recall that EmailAddresses cannot be deleted if they are tied to a mailing list, even an purged one.

Curtis Hovey (sinzui)
Changed in launchpad-registry:
status: In Progress → Fix Committed
Curtis Hovey (sinzui)
tags: added: qa-ok
Revision history for this message
Launchpad QA Bot (lpqabot) wrote : Bug fixed by a commit
tags: added: qa-needstesting
removed: qa-ok
Curtis Hovey (sinzui)
tags: added: qa-ok
removed: qa-needstesting
Curtis Hovey (sinzui)
Changed in launchpad-registry:
status: Fix Committed → Fix Released
Curtis Hovey (sinzui)
Changed in launchpad:
assignee: Curtis Hovey (sinzui) → nobody
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.