fix(contacts): persist all documented fields on create (fixes #716)
create_contact previously read only fn/email/tel from contact_data and silently dropped org, organization, note, title, nickname, bday, categories, url — and didn't accept phone as an alias for tel, so the reporter's exact call lost every field except fn and email. Introduce _build_contact_from_data, share it with update_contact's fallback, and normalise str→list inputs so pythonvCard4 doesn't iterate bare strings character-by-character for list-typed properties. Closes #716 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
d766f3c014
commit
723aee9134
@@ -24,6 +24,9 @@ async def test_mcp_contacts_workflow(
|
||||
"fn": f"MCP Contact {unique_suffix}",
|
||||
"email": f"mcp.contact.{unique_suffix}@example.com",
|
||||
"tel": "1234567890",
|
||||
# Regression for issue #716 — these were silently dropped before
|
||||
"organization": "MCP Test Corp",
|
||||
"note": f"Created by test {unique_suffix}",
|
||||
}
|
||||
|
||||
try:
|
||||
@@ -51,9 +54,13 @@ async def test_mcp_contacts_workflow(
|
||||
)
|
||||
assert create_c_result.isError is False
|
||||
|
||||
# 4. Verify contact creation
|
||||
# 4. Verify contact creation (and that all fields — #716 — actually persisted)
|
||||
contacts = await nc_client.contacts.list_contacts(addressbook=addressbook_name)
|
||||
assert any(c["vcard_id"] == contact_uid for c in contacts)
|
||||
created = next((c for c in contacts if c["vcard_id"] == contact_uid), None)
|
||||
assert created is not None
|
||||
raw_vcard = created.get("addressdata", "")
|
||||
assert "ORG:MCP Test Corp" in raw_vcard
|
||||
assert f"NOTE:Created by test {unique_suffix}" in raw_vcard
|
||||
|
||||
# 5. Delete contact via MCP
|
||||
logger.info(f"Deleting contact {contact_uid} via MCP")
|
||||
|
||||
Reference in New Issue
Block a user