fix(deck): address review — notesPath key, scopes, modernize types
PR #781 review round 1: - 🔴 Fix notesPath key: the Notes API returns the folder under camelCase ``notesPath`` (see models/notes.py:43), but `deck_attach_note` was looking up snake_case ``notes_path`` and silently falling back to ``"Notes"``. Users with a non-default notes folder would have produced shares pointing at non-existent files (404 on click in Deck UI). - 🔴 Add wire-through unit test that would have caught the above: extract `_resolve_note_attach_path(client, note_id)` as a testable helper that encapsulates the camelCase-key lookup. Three new tests: custom notesPath honored, missing key falls back to default, null category handled. - 🟡 Modernize new fields on `DeckAttachmentExtendedData` to PEP 604 (`X | None`) per CLAUDE.md. - 🟡 Drop unnecessary string forward reference on `ListAttachmentsResponse.results` — DeckAttachment is defined earlier in the same module. - 🟢 Move `pytestmark = pytest.mark.unit` to module level in test_sharing_client.py to match the convention in test_deck_server.py. Per user request: `deck_attach_file` is now scoped `deck.write` + ``files.read`` (was just `deck.write`) so the generic file-share permission story is consistent — only `deck_attach_note` keeps `notes.read` since it specifically reads from the Notes app. Docstring updated to emphasise the tool is generic over the user's Files (PDFs/images/etc., not just markdown). 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
c0a974c498
commit
271904c227
@@ -145,10 +145,10 @@ class DeckAttachmentExtendedData(BaseModel):
|
||||
mimetype: str
|
||||
info: Dict[str, str]
|
||||
# Populated for type="file" (Files share) attachments via FilesAppService.
|
||||
path: Optional[str] = None
|
||||
fileid: Optional[int] = None
|
||||
hasPreview: Optional[bool] = None
|
||||
permissions: Optional[int] = None
|
||||
path: str | None = None
|
||||
fileid: int | None = None
|
||||
hasPreview: bool | None = None
|
||||
permissions: int | None = None
|
||||
|
||||
|
||||
class DeckAttachment(BaseModel):
|
||||
@@ -336,7 +336,7 @@ class AttachFileResponse(BaseResponse):
|
||||
class ListAttachmentsResponse(BaseResponse):
|
||||
"""Response model for listing card attachments."""
|
||||
|
||||
results: list["DeckAttachment"] = Field(
|
||||
results: list[DeckAttachment] = Field(
|
||||
description="Attachments on the card (both type='file' and type='deck_file')"
|
||||
)
|
||||
count: int = Field(description="Number of attachments returned")
|
||||
|
||||
Reference in New Issue
Block a user