fix: address PR review feedback (round 3)

Bugs:
- assign_tag/remove_tag now call _unwrap_ocs to surface OCS-level errors
- trash_page changed to idempotentHint=False (trashing twice errors)
- WebDAV path parts stripped of slashes to prevent double-slash paths

Robustness:
- _unwrap_ocs uses ocs.get("data", {}) instead of ocs["data"]
- Unit test added for missing data key in OCS envelope

Minor:
- MCP error codes use -1 (project convention) instead of HTTP status codes
- update_collective docstring notes that emoji is required
- CollectiveTag.color validated as hex format via field_validator

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Chris Coutinho
2026-03-25 13:25:09 +01:00
co-authored by Claude Opus 4.6
parent 44a27bd9e9
commit f3caad122d
4 changed files with 45 additions and 13 deletions
+5 -3
View File
@@ -40,7 +40,7 @@ class CollectivesClient(BaseNextcloudClient):
if status_code >= 400:
message = meta.get("message", "OCS error")
raise OCSError(status_code, message)
return ocs["data"]
return ocs.get("data", {})
# Collectives
@@ -215,19 +215,21 @@ class CollectivesClient(BaseNextcloudClient):
async def assign_tag(self, collective_id: int, page_id: int, tag_id: int) -> None:
"""Assign a tag to a page."""
await self._make_request(
response = await self._make_request(
"PUT",
f"{API_BASE}/collectives/{collective_id}/pages/{page_id}/tags/{tag_id}",
headers=self._get_ocs_headers(),
)
self._unwrap_ocs(response.json())
async def remove_tag(self, collective_id: int, page_id: int, tag_id: int) -> None:
"""Remove a tag from a page."""
await self._make_request(
response = await self._make_request(
"DELETE",
f"{API_BASE}/collectives/{collective_id}/pages/{page_id}/tags/{tag_id}",
headers=self._get_ocs_headers(),
)
self._unwrap_ocs(response.json())
# Trash