fix(deck): Always preserve fields in update_card for partial updates

The Deck PUT API is a full replacement, not a partial update.
Previously, title and description were conditionally sent, causing:
- 400 errors when title not provided (it's required)
- Description being cleared when not explicitly set

Now all required fields (title, type, owner) and description are
always included in the payload using current card values when not
explicitly provided. This matches the existing pattern for type/owner.

Also simplified owner extraction since DeckCard.validate_owner
already ensures it's always a string.

Fixes #452

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Chris Coutinho
2025-12-30 23:30:01 -06:00
co-authored by Claude Opus 4.5
parent 71ace47197
commit a26a470af6
+15 -20
View File
@@ -285,28 +285,23 @@ class DeckClient(BaseNextcloudClient):
archived: Optional[bool] = None, archived: Optional[bool] = None,
done: Optional[str] = None, done: Optional[str] = None,
) -> None: ) -> None:
# First, get the current card to use existing values for required fields # Deck PUT API is a full replacement - all required fields must be sent.
# Fetch current card to preserve values for fields not being updated.
current_card = await self.get_card(board_id, stack_id, card_id) current_card = await self.get_card(board_id, stack_id, card_id)
json_data = {} # Build payload with required fields always included
if title is not None: json_data = {
json_data["title"] = title # Title is required by the API
if description is not None: "title": title if title is not None else current_card.title,
json_data["description"] = description # Type is required by the API
# Type is required by the API, use provided or keep current "type": type if type is not None else current_card.type,
json_data["type"] = type if type is not None else current_card.type # Owner is required by the API (model validator ensures it's a string)
# Owner is required by the API, use provided or keep current "owner": owner if owner is not None else current_card.owner,
json_data["owner"] = ( # Description must be sent to preserve it (PUT clears omitted fields)
owner "description": description
if owner is not None if description is not None
else ( else (current_card.description or ""),
current_card.owner }
if isinstance(current_card.owner, str)
else current_card.owner.uid
if hasattr(current_card.owner, "uid")
else current_card.owner.primaryKey
)
)
if order is not None: if order is not None:
json_data["order"] = order json_data["order"] = order
if duedate is not None: if duedate is not None: