siyuan-note/siyuan · error

CardDAV: address not found

Error message

CardDAV: address not found

What it means

Sentinel error ErrorCardDavAddressNotFound, thrown when a CardDAV GET/PUT/DELETE operation references an address object (vCard) that does not exist under the resolved address book path. It is part of the CardDAV server error set declared in kernel/model/carddav.go and is used by the WebDAV/CardDAV handler stack to map to an HTTP 404. The error is a package-level var, so it is meant to be compared with errors.Is rather than string matching.

Source

Thrown at kernel/model/carddav.go:96

		Name:                 CardDavDefaultAddressBookName,
		Description:          "Default address book",
		MaxResourceSize:      addressBookMaxResourceSize,
		SupportedAddressData: addressBookSupportedAddressData,
	}
	contacts = Contacts{
		loaded:        false,
		changed:       false,
		lock:          sync.Mutex{},
		books:         sync.Map{},
		booksMetaData: []*carddav.AddressBook{},
	}

	ErrorCardDavPathInvalid = errors.New("CardDAV: path is invalid")

	ErrorCardDavBookNotFound    = errors.New("CardDAV: address book not found")
	ErrorCardDavBookPathInvalid = errors.New("CardDAV: address book path is invalid")

	ErrorCardDavAddressNotFound                 = errors.New("CardDAV: address not found")
	ErrorCardDavAddressFileExtensionNameInvalid = errors.New("CardDAV: address file extension name is invalid")
)

// ImportAddressBook imports an address book from a vCard file (*.vcf)
func ImportAddressBook(addressBookPath, cardContent string) (addresses []*AddressObject, err error) {
	// TODO: Check whether the path is valid (PathDepth: Address)
	// TODO: Check whether the address book exists
	// TODO: Decode the card content
	// TODO: Save the cards to the file system
	return
}

// ExportAddressBook exports an address book to a vCard file (*.vcf)
func ExportAddressBook(addressBookPath string) (cardContent string, err error) {
	// TODO: Check whether the path is valid (PathDepth: AddressBook)
	// TODO: Check whether the address book exists
	// TODO: Encode the card content
	return

View on GitHub (pinned to 251596fc0d)

Solutions

  1. Verify the resource URL matches an href previously returned by a PROPFIND/REPORT on the address book collection.
  2. Re-run an address-book-query REPORT to refresh the client's list of valid hrefs, then retry only against existing resources.
  3. If the object is expected to exist, check the address book directory on disk for the corresponding .vcf file and confirm no sync/history operation removed it.
  4. Handle the 404 gracefully on the client side by dropping the local copy of the deleted contact.

Example fix

// before: client constructs URL by guess
url := baseURL + "/default/" + guessedID + ".vcf"

// after: use only hrefs returned by the server
for _, href := range propfindResults.Hrefs {
    get(href) // never fabricate hrefs
}
Defensive patterns

Strategy: validation

Validate before calling

// Before issuing a CardDAV GET/PUT/DELETE, confirm the href came from a prior PROPFIND
func isKnownHref(href string, known []string) bool {
    for _, k := range known {
        if k == href { return true }
    }
    return false
}

Type guard

// Resource paths must end in .vcf and reference a known href
func isValidAddressHref(href string) bool {
    return strings.HasSuffix(href, ".vcf")
}

Try / catch

if errors.Is(err, model.ErrorCardDavAddressNotFound) { /* refresh hrefs via REPORT, then retry or drop the contact */ }

Prevention

When it happens

Trigger: A CardDAV client (macOS Contacts, DAVx5, Thunderbird) requests or modifies an address resource by URL whose final path segment does not match any stored .vcf object inside the address book directory. Also produced when an address object was deleted between a PROPFIND and a subsequent GET, or when the path depth check (PathDepth: Address) passes but the file is absent on disk.

Common situations: Stale address cache on the client after another device deleted the contact; client guessed a URL instead of using the href returned by PROPFIND; address book folder was partially restored from backup and is missing .vcf files; two clients racing on the same contact.

Related errors


AI-assisted analysis of siyuan-note/siyuan@251596fc0d (2026-08-12). Data as JSON: /api/errors/3e7ecc087283f49f. Report an issue: GitHub.