{"record":{"id":"3e7ecc087283f49f","repo":"siyuan-note/siyuan","slug":"carddav-address-not-found","errorCode":null,"errorMessage":"CardDAV: address not found","messagePattern":"CardDAV: address not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/carddav.go","lineNumber":98,"sourceCode":"\t\tName:                 CardDavDefaultAddressBookName,\n\t\tDescription:          \"Default address book\",\n\t\tMaxResourceSize:      addressBookMaxResourceSize,\n\t\tSupportedAddressData: addressBookSupportedAddressData,\n\t}\n\tcontacts = Contacts{\n\t\tloaded:        false,\n\t\tchanged:       false,\n\t\tlock:          sync.Mutex{},\n\t\tbooks:         sync.Map{},\n\t\tbooksMetaData: []*carddav.AddressBook{},\n\t}\n\n\tErrorCardDavPathInvalid = errors.New(\"CardDAV: path is invalid\")\n\n\tErrorCardDavBookNotFound    = errors.New(\"CardDAV: address book not found\")\n\tErrorCardDavBookPathInvalid = errors.New(\"CardDAV: address book path is invalid\")\n\n\tErrorCardDavAddressNotFound                 = errors.New(\"CardDAV: address not found\")\n\tErrorCardDavAddressFileExtensionNameInvalid = errors.New(\"CardDAV: address file extension name is invalid\")\n)\n\n// ImportAddressBook imports an address book from a vCard file (*.vcf)\nfunc ImportAddressBook(addressBookPath, cardContent string) (addresses []*AddressObject, err error) {\n\t// TODO: Check whether the path is valid (PathDepth: Address)\n\t// TODO: Check whether the address book exists\n\t// TODO: Decode the card content\n\t// TODO: Save the cards to the file system\n\treturn\n}\n\n// ExportAddressBook exports an address book to a vCard file (*.vcf)\nfunc ExportAddressBook(addressBookPath string) (cardContent string, err error) {\n\t// TODO: Check whether the path is valid (PathDepth: AddressBook)\n\t// TODO: Check whether the address book exists\n\t// TODO: Encode the card content\n\treturn","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/carddav.go#L80-L116","documentation":"CardDAV: address not found is a sentinel error (kernel/model/carddav.go:98) returned by GetAddress and DeleteAddress when the requested vCard address object is not present in the address book store. The lookup resolves the address path against an in-memory/cache map; if the key is absent (nil value or wrong type), this error is returned at carddav.go:282 and carddav.go:306. It signals the address (card) does not exist, not that the book is malformed.","triggerScenarios":"Calling GetAddress or DeleteAddress with a path whose address object was never imported, was deleted, or whose key was evicted from the address book map. Also occurs if the stored value's type assertion to *AddressObject fails (map miss in the else branch).","commonSituations":"Client cached a CardDAV href that was removed on another device or by another sync run; requesting a card before ImportAddressBook populated the book; a stale ETag/URL after the workspace data directory was replaced or restored from backup.","solutions":["Verify the address path/href exists by listing the address book contents (e.g. via the CardDAV PROPFIND/report or the imported addresses from ImportAddressBook) before calling GetAddress/DeleteAddress","Re-import the address book with ImportAddressBook if the data directory was restored or the card file was deleted","Check the path spelling and depth: the card file must be a *.vcf inside a valid address book path (otherwise different errors like ErrorCardDavAddressFileExtensionNameInvalid fire)","Handle the sentinel with errors.Is(ErrorCardDavAddressNotFound) and treat it as HTTP 404 toward the CardDAV client rather than a 500"],"exampleFix":"// before\ntypeAssertion := store[key].(*AddressObject)\n\n// after\nvalue, ok := store[key]\nif !ok {\n    return ErrCardDavAddressNotFound // sentinel; map to 404\n}\naddressObject, ok := value.(*AddressObject)\nif !ok {\n    return ErrCardDavAddressNotFound\n}","handlingStrategy":"validation","validationCode":"// Go\nif !addressBookContains(book, addressID) { // list/check before fetch\n    return ErrCardDavAddressNotFound\n}","typeGuard":"value, ok := store[key].(*AddressObject)\nif !ok { return ErrCardDavAddressNotFound }","tryCatchPattern":null,"preventionTips":["Always import the address book (ImportAddressBook) before resolving individual addresses","Treat the sentinel with errors.Is and map it to 404, not 500","Purge client-side caches of CardDAV hrefs after any data restore or delete"],"tags":["carddav","not-found","addressbook"],"backgroundTag":"record-not-found","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}