monicahq/monica · error · DavClientException

No address book found

Error message

No address book found

What it means

AddressBookGetter::getAddressBookBaseUri() tries three strategies to locate an address book collection: (1) walk the supplied URI path segment by segment with Depth-0 PROPFINDs looking for a {card:}addressbook resourcetype, (2) fall back to principal discovery on the original path, (3) fall back to the /.well-known-derived service URL. Every strategy's HTTP errors are silently caught, so if all attempts end with null this DavClientException is thrown: the server answered, but no address book was found for those credentials at that URL.

Source

Thrown at app/Domains/Contact/DavClient/Services/Utils/AddressBookGetter.php:111

                // Catch error
            }
        }

        // If no address book found, try with the service url
        if ($addressBookUrl === null) {
            $serviceUrl = $this->client->getServiceUrl();

            if ($serviceUrl !== null) {
                try {
                    $addressBookUrl = $this->getAddressBookForUri($serviceUrl);
                } catch (\Illuminate\Http\Client\RequestException $e) {
                    // Catch error
                }
            }
        }

        if ($addressBookUrl === null) {
            throw new DavClientException('No address book found');
        }

        $addressBookUrl = $this->client->path(parse_url($addressBookUrl, PHP_URL_PATH));

        if (! Str::contains($addressBookUrl, 'https://www.googleapis.com')) {
            // Check the OPTIONS of the server
            $this->checkOptions(true, $addressBookUrl);
        }

        return $addressBookUrl;
    }

    /**
     * Calculate address book base uri.
     */
    private function getAddressBookForUri(string $uri = ''): ?string
    {
        // Get the principal of this account

View on GitHub (pinned to e08e917341)

Solutions

  1. Create at least one address book in the remote server's UI for that account, then retry the subscription
  2. Point base_uri directly at the address book collection (e.g. https://cloud.example.com/remote.php/dav/addressbooks/users/USER/personal/) so the Depth-0 walk succeeds
  3. Confirm discovery works: curl -u user:pass -X PROPFIND -H 'Depth: 1' <home-set-url> must list a child whose resourcetype includes addressbook
  4. Verify the discovery requests are authenticated — a swallowed 401 is indistinguishable from 'no address book'
Defensive patterns

Strategy: validation

Validate before calling

// Preflight: confirm the home-set actually contains an addressbook collection before subscribing
$books = $davClient->propfind('{DAV:}resourcetype', depth: 1, url: $homeSetUrl);
$hasAddressBook = collect($books)
    ->contains(fn ($props) => Arr::get($props, '{DAV:}resourcetype')?->is('{urn:ietf:params:xml:ns:carddav}addressbook'));

if (! $hasAddressBook) {
    throw ValidationException::withMessages([
        'base_uri' => 'No address book found on this server for these credentials. Create one first.',
    ]);
}

Try / catch

try {
    app(CreateAddressBookSubscription::class)->execute($data);
} catch (DavClientException $e) {
    if (str_contains($e->getMessage(), 'No address book found')) {
        // guide the user: create an address book on the server, or supply the direct collection URL
    }
    throw $e;
}

Prevention

When it happens

Trigger: Subscribing with credentials/URL where no address book collection is discoverable: a freshly created radicale/Nextcloud user with zero address books, a CalDAV-only server, a Depth-1 PROPFIND on the home-set returning no addressbook child, or a 401 on every discovery PROPFIND (auth failure is swallowed and looks identical to 'not found').

Common situations: New remote account without an address book created yet, wrong username format (UPN vs email), base_uri aimed at a CalDAV endpoint, or credentials that fail authentication so each discovery request silently errors out.

Related errors


AI-assisted analysis of monicahq/monica@e08e917341 (2026-08-17). Data as JSON: /api/errors/ab42f36e338dffb6. Report an issue: GitHub.