siyuan-note/siyuan · error

CardDAV: path is invalid

Error message

CardDAV: path is invalid

What it means

ErrorCardDavPathInvalid is the generic path-shape error of the CardDAV layer, returned by QueryAddressObjects when the request path matches none of the recognized CardDAV path shapes (the default branch of the depth/shape switch). It indicates a URL that is neither the root, an address book, nor an address object path.

Solutions

  1. Use a path returned by the CardDAV discovery/listing endpoints
  2. Verify the configured CardDAV base URL has the expected segment layout
  3. Check GetCardDavPathDepth of your path against the supported depths before calling

Example fix

// before
QueryAddressObjects("/dav/carddav/some/deep/nested/path/")
// after
QueryAddressObjects("/dav/carddav/addressbooks/mybook/")
Defensive patterns

Strategy: validation

Validate before calling

depth := GetCardDavPathDepth(p)
if depth != cardDavPathDepth_Book && depth != cardDavPathDepth_Address {
    return fmt.Errorf("unrecognized CardDAV path: %q", p)
}

Try / catch

if errors.Is(err, ErrorCardDavPathInvalid) {
    // re-discover the CardDAV collection layout and retry with valid hrefs
}

Prevention

When it happens

Trigger: QueryAddressObjects invoked with a path whose structure hits the switch's default case, i.e. an unrecognized depth or segment arrangement.

Common situations: CalDAV/CardDAV clients probing unknown collections; hand-built URLs with wrong segment counts; clients configured with a wrong principal/collection base path.

Understand the failure class

Background: "Invalid URL" errors: why new URL(), URI.parse, and reqwest::Url reject your string — missing scheme, whitespace, and bad path format — this error's family across 39 libraries.

Related errors


AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19). Data as JSON: /api/errors/3745aeede8ec6bad. Report an issue: GitHub.

Appendix: source

Thrown at kernel/model/carddav.go:93

		},
	}

	defaultAddressBook = carddav.AddressBook{
		Path:                 CardDavDefaultAddressBookPath,
		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)

View on GitHub (pinned to 9f775e8a12)