Skip to content

Commit 34d172a

Browse files
committed
fix(teams): scope file delivery to post_message only (upstream fidelity)
The initial port wired filesToAttachments into both post_message AND edit_message. Upstream vercel/chat wires it into postMessage + postChannelMessage only — editMessage never carries files. And chinchill delivers execution artifacts via a fresh post(), never by editing files into an existing message. Carrying files in edit_message was an unrequested divergence (and an edit_message+files test has no upstream counterpart, which the repo's verify_test_fidelity gate would flag). Revert edit_message to file-free, mirroring upstream. Replace the edit_message+file test with a fidelity guard asserting edit_message carries no file attachments. post_message file delivery (the actual parity fix) is unchanged.
1 parent c89bfc9 commit 34d172a

2 files changed

Lines changed: 21 additions & 14 deletions

File tree

src/chat_sdk/adapters/teams/adapter.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,14 +1171,18 @@ async def edit_message(
11711171
message_id: str,
11721172
message: AdapterPostableMessage,
11731173
) -> RawMessage:
1174-
"""Edit an existing Teams message."""
1174+
"""Edit an existing Teams message.
1175+
1176+
Note: file delivery is intentionally NOT wired here. Upstream
1177+
``vercel/chat`` ports ``filesToAttachments`` into ``postMessage`` and
1178+
``postChannelMessage`` only — ``editMessage`` does not carry files — and
1179+
chinchill delivers execution artifacts via a fresh ``post`` (never by
1180+
editing files into an existing message). Keeping ``edit_message``
1181+
file-free preserves upstream fidelity.
1182+
"""
11751183
decoded = self.decode_thread_id(thread_id)
11761184

1177-
files = extract_files(message)
1178-
file_attachments = await self._files_to_attachments(files) if files else []
1179-
11801185
card = extract_card(message)
1181-
activity_payload: dict[str, Any]
11821186
if card:
11831187
adaptive_card = card_to_adaptive_card(card)
11841188
activity_payload = {
@@ -1188,7 +1192,6 @@ async def edit_message(
11881192
"contentType": "application/vnd.microsoft.card.adaptive",
11891193
"content": adaptive_card,
11901194
},
1191-
*file_attachments,
11921195
],
11931196
}
11941197
else:
@@ -1201,8 +1204,6 @@ async def edit_message(
12011204
"text": text,
12021205
"textFormat": "markdown",
12031206
}
1204-
if file_attachments:
1205-
activity_payload["attachments"] = file_attachments
12061207

12071208
self._logger.debug(
12081209
"Teams API: updateActivity",

tests/test_teams_adapter.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,13 @@ async def test_card_message_with_file(self):
764764
assert file_att["contentUrl"].startswith("data:image/png;base64,")
765765

766766
@pytest.mark.asyncio
767-
async def test_edit_message_with_file(self):
767+
async def test_edit_message_does_not_carry_files(self):
768+
"""Upstream fidelity: ``editMessage`` never delivers files (upstream wires
769+
``filesToAttachments`` into ``postMessage``/``postChannelMessage`` only), and
770+
chinchill delivers execution artifacts via a fresh ``post`` — never by editing
771+
files into an existing message. A ``PostableMarkdown`` carrying files must edit
772+
the text only, with no file attachments on the activity.
773+
"""
768774
from chat_sdk.types import FileUpload, PostableMarkdown
769775

770776
adapter = _make_adapter(app_id="test-app-id", logger=_make_logger())
@@ -777,11 +783,11 @@ async def test_edit_message_with_file(self):
777783
result = await adapter.edit_message(self._thread_id(adapter), "edit-1", message)
778784

779785
payload = adapter._teams_update.call_args.args[2]
780-
attachments = payload["attachments"]
781-
assert len(attachments) == 1
782-
assert attachments[0]["contentType"] == "text/plain"
783-
assert attachments[0]["name"] == "note.txt"
784-
assert attachments[0]["contentUrl"].startswith("data:text/plain;base64,")
786+
assert "attachments" not in payload, (
787+
"edit_message must not carry file attachments — outbound file delivery is "
788+
f"post_message-only (upstream fidelity); got attachments={payload.get('attachments')!r}"
789+
)
790+
assert payload["text"] == "updated"
785791
assert result.id == "edit-1"
786792

787793
@pytest.mark.asyncio

0 commit comments

Comments
 (0)