fix: convert BDAY datetime.date to string before Pydantic validation

pythonvCard4 parses vCard BDAY fields into datetime.date objects, but
the Contact model expects Optional[str]. This caused a validation error
that crashed the entire contact list. Convert at the client layer
(consistent with the calendar client pattern) with a defensive check
at the server mapping layer.

Closes #672

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Chris Coutinho
2026-04-01 09:11:45 +02:00
co-authored by Claude Opus 4.6
parent 97ae750916
commit da380a38c6
3 changed files with 50 additions and 2 deletions
+4 -1
View File
@@ -2,6 +2,7 @@
import logging
import xml.etree.ElementTree as ET
from datetime import date
from pythonvCard4.vcard import Contact
@@ -272,7 +273,9 @@ class ContactsClient(BaseNextcloudClient):
"contact": {
"fullname": contact.fn,
"nickname": contact.nickname,
"birthday": contact.bday,
"birthday": contact.bday.isoformat()
if isinstance(contact.bday, date)
else contact.bday,
"email": contact.email,
"tel": contact.tel,
},