{"record":{"id":"d3959c4ee6330f55","repo":"monicahq/monica","slug":"server-does-not-support-rfc-5397-section-3-dav-cu","errorCode":null,"errorMessage":"Server does not support rfc 5397 section 3 (DAV:current-user-principal)","messagePattern":"Server does not support rfc 5397 section 3 \\(DAV:current-user-principal\\)","errorType":"exception","errorClass":"DavServerNotCompliantException","httpStatus":null,"severity":"error","filePath":"app/Domains/Contact/DavClient/Services/Utils/AddressBookGetter.php","lineNumber":171,"sourceCode":"\n        if (! in_array('1', $options) || ! in_array('3', $options) || ($addressbook && ! in_array('addressbook', $options))) {\n            throw new DavServerNotCompliantException('server is not compliant with rfc2518 section 15.1, or rfc6352 section 6.1');\n        }\n    }\n\n    /**\n     * Get principal name.\n     *\n     * @see https://datatracker.ietf.org/doc/html/rfc5397#section-3\n     *\n     * @throws DavServerNotCompliantException\n     */\n    private function getCurrentUserPrincipal(string $uri = ''): string\n    {\n        $prop = $this->client->getProperty('{DAV:}current-user-principal', $uri);\n\n        if (is_null($prop) || empty($prop)) {\n            throw new DavServerNotCompliantException('Server does not support rfc 5397 section 3 (DAV:current-user-principal)');\n        } elseif (is_string($prop)) {\n            return $prop;\n        }\n\n        return $prop[0]['value'];\n    }\n\n    /**\n     * Get addressbook url.\n     *\n     * @see https://datatracker.ietf.org/doc/html/rfc6352#section-7.1.1\n     *\n     * @throws DavServerNotCompliantException\n     */\n    private function getAddressBookHome(string $principal): string\n    {\n        $prop = $this->client->getProperty('{'.CardDav::NS_CARDDAV.'}addressbook-home-set', $principal);\n","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/monicahq/monica/blob/e08e91734170b6bbd582cb578532c3948196124e/app/Domains/Contact/DavClient/Services/Utils/AddressBookGetter.php#L153-L189","documentation":"During principal discovery, getAddressBookForUri() issues a PROPFIND for {DAV:}current-user-principal on the given URI. RFC 5397 section 3 requires servers to return this property so clients can bootstrap from any URL to the user's principal. When getProperty returns null or empty (404 propstat, or an unauthenticated response that hides the principal), this DavServerNotCompliantException is thrown.","triggerScenarios":"A Depth-0 PROPFIND on the supplied URI does not return {DAV:}current-user-principal: older or non-standard CardDAV servers, servers that only reveal the principal to authenticated requests while the request went out unauthenticated, or a base_uri that routes to a plain web page instead of a DAV endpoint.","commonSituations":"base_uri pointing at the server's login page or web root rather than the DAV endpoint, a CardDAV server predating RFC 5397, or rejected credentials so the server answers without principal information.","solutions":["Point base_uri directly at the address book collection URL so the earlier resourcetype walk succeeds and principal discovery is never needed","Verify the property manually with an authenticated PROPFIND asking for current-user-principal on the URI and confirm the response contains an href","Confirm authentication is sent and accepted on the discovery request (unauthenticated servers may omit the property)","Upgrade the remote CardDAV server to an RFC 5397-compliant version"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Preflight: confirm the server returns {DAV:}current-user-principal for an authenticated PROPFIND\n$prop = $davClient->getProperty('{DAV:}current-user-principal', $uri);\n\nif (is_null($prop) || empty($prop)) {\n    throw ValidationException::withMessages([\n        'base_uri' => 'Server does not support RFC 5397 principal discovery; supply the direct address book URL.',\n    ]);\n}","typeGuard":null,"tryCatchPattern":"use App\\Domains\\Contact\\DavClient\\Services\\Utils\\Dav\\DavServerNotCompliantException;\n\ntry {\n    app(CreateAddressBookSubscription::class)->execute($data);\n} catch (DavServerNotCompliantException $e) {\n    if (str_contains($e->getMessage(), 'rfc 5397')) {\n        // fall back: ask the user for the exact address book collection URL\n    }\n    throw $e;\n}","preventionTips":["When the server lacks RFC 5397, configure the address book collection URL directly so the resourcetype path walk succeeds without principal discovery","Ensure discovery requests carry credentials — some servers omit the principal property when anonymous","Upgrade non-compliant CardDAV servers rather than working around them","Log the failing URI in observability output to distinguish which discovery step threw"],"tags":["carddav","dav","rfc5397","principal","discovery"],"backgroundTag":"dav-principal-discovery-failed","analyzedSha":"e08e91734170b6bbd582cb578532c3948196124e","analyzedAt":"2026-08-17T01:36:49.014Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}