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
+11 -2
View File
@@ -1,6 +1,8 @@
"""Pydantic models for Nextcloud Collectives app."""
from pydantic import BaseModel, Field
import re
from pydantic import BaseModel, Field, field_validator
from .base import BaseResponse, StatusResponse
@@ -53,7 +55,14 @@ class CollectiveTag(BaseModel):
id: int = Field(description="Tag ID")
collectiveId: int = Field(description="Parent collective ID")
name: str = Field(description="Tag name")
color: str = Field(description="Hex color code")
color: str = Field(description="Hex color code (e.g. 'FF0000')")
@field_validator("color")
@classmethod
def validate_hex_color(cls, v: str) -> str:
if not re.fullmatch(r"[0-9A-Fa-f]{3,8}", v):
raise ValueError(f"Invalid hex color: {v!r}")
return v
# Response Models