Closed Bug 2088411 Opened 23 days ago Closed 20 days ago

Account Hub: CardDAV address book setup fails with "known to be incompatible" when an address book without dirPrefId exists (regression of bug 1763599)

Categories

(Thunderbird :: Account Manager, defect)

Thunderbird 153
x86_64
Windows 11
defect

Tracking

(thunderbird_esr153 wontfix, thunderbird161 wontfix)

RESOLVED FIXED
162 Branch
Tracking Status
thunderbird_esr153 --- wontfix
thunderbird161 --- wontfix

People

(Reporter: mail, Assigned: mkmelin)

References

(Regression)

Details

(Keywords: regression)

Attachments

(1 external file)

Steps to reproduce

  1. Have an address book in the profile that has no dirPrefId, e.g. a Global Address List provided by the EAS-4-TbSync add-on (searchaddr://eas-gal-N, dirType 103 / ASYNC_DIRECTORY_TYPE).
  2. Start adding a CardDAV address book through the new Account Hub (address book flow).
  3. Enter username and server URL of a working CardDAV server and authenticate.

Actual results

The Account Hub shows "<hostname> is known to be incompatible with Thunderbird" and aborts. The server is not incompatible: CardDAV discovery succeeds, and the error happens afterwards while checking for existing address books.

Error console:

NS_ERROR_NOT_AVAILABLE: No dirPrefId!
mail.setup: Account setup error: No dirPrefId!
  get _prefBranch                 resource:///modules/AddrBookDirectory.sys.mjs:77
  getStringValue                  resource:///modules/AddrBookDirectory.sys.mjs:842
  updateExistingAddressBooks      resource:///modules/accountcreation/RemoteAddressBookUtils.sys.mjs:36
  ensureInitialized               resource:///modules/accountcreation/RemoteAddressBookUtils.sys.mjs:46
  get list                        resource:///modules/accountcreation/RemoteAddressBookUtils.sys.mjs:76
  markExistingAddressBooks        resource:///modules/accountcreation/RemoteAddressBookUtils.sys.mjs:209
  getAddressBooksForAccount       resource:///modules/accountcreation/RemoteAddressBookUtils.sys.mjs:197
  #initializeSyncSubview          chrome://messenger/content/accountcreation/views/address-book.mjs:515

Directories in the affected profile (Browser Console):

101 jsaddrbook://abook.sqlite   | ldap_2.servers.pab   | carddav.url: <empty>
102 jscarddav://abook-4.sqlite  | ldap_2.servers.Tine… | carddav.url: https://…/addressbooks/…/
103 searchaddr://eas-gal-5      | dirPrefId: <empty>   | getStringValue → No dirPrefId!
103 searchaddr://eas-gal-6      | dirPrefId: <empty>   | getStringValue → No dirPrefId!

Analysis

existingCardDAVBooks.updateExistingAddressBooks() in RemoteAddressBookUtils.sys.mjs calls getStringValue("carddav.url", "") on every directory:

this._list = new Set(
  lazy.MailServices.ab.directories
    .map(directory => directory.getStringValue("carddav.url", ""))
    .filter(Boolean)
);

For directories without a dirPrefId, AddrBookDirectory._prefBranch throws NS_ERROR_NOT_AVAILABLE. That error code is then shown as the misleading "known to be incompatible" message.

This is a regression of bug 1763599. The old dialog (abCardDAVDialog.js) filters on dirType == Ci.nsIAbManager.CARDDAV_DIRECTORY_TYPE, but that filter was lost when the logic was reimplemented for the Account Hub.

Suggested fix

this._list = new Set(
  lazy.MailServices.ab.directories
    .filter(d => d.dirType == Ci.nsIAbManager.CARDDAV_DIRECTORY_TYPE)
    .map(d => d.getStringValue("carddav.url", ""))
    .filter(Boolean)
);

Optionally also use a per-directory try/catch so one broken directory cannot break the flow. Error handling should also not map every NS_ERROR_NOT_AVAILABLE to "known to be incompatible", since that message is meant only for the PRESETS blocklist in CardDAVUtils.detectAddressBooks().

Verified locally: patching AddrBookDirectory.prototype.getStringValue at runtime to return the default when dirPrefId is missing makes the Account Hub flow work.

Workaround

Use the old dialog (Address Book → New Address Book → Add CardDAV Address Book) or temporarily disable the add-on providing the directory.

Expected results

The address books found on the server are listed in the Account Hub and can be added. Directories that are not CardDAV directories (or have no dirPrefId) must not break the check for already existing address books, just as in the old CardDAV dialog after bug 1763599.

See Also: → 1763599
OS: Unspecified → Windows 11
Hardware: Unspecified → x86_64

Regressed from a few bugs. Bug 1972813 is for the exact code hit

Assignee: nobody → mkmelin+mozilla
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Keywords: regression
Regressed by: 1972813
Target Milestone: --- → 162 Branch

Pushed by mkmelin@iki.fi:
https://hg.mozilla.org/comm-central/rev/b9c8f915d6a5
Only consider CardDAV directories when checking for existing address books in the Account Hub. r=freaktechnik

Status: ASSIGNED → RESOLVED
Closed: 20 days ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: