Skip to content

Adaptive Card Attachments Result in Error For ConversationOperations send_to_conversation #312

@jroy-sophos

Description

@jroy-sophos

Bug: send_to_conversation crashes on 202 with empty body due to forced JSON decode

SDK Version: 0.7.0
File: microsoft_agents/hosting/core/connector/client/connector_client.py
Function: ConversationsOperations.send_to_conversation
Line: ~272 (await data = await response.json())

Summary

When sending an activity that includes an attachment, the service may return HTTP 202 Accepted with no response body.
The SDK still executes await response.json(), which causes a failure because the body is empty or the mimetype is not JSON. This does not prevent the message from being sent, and we are receiving the message in the expected channel.

We have discovered this when updating a legacy application to use the new SDK. We are using Adaptive Cards for several purposes, and we had previously used the Connector Client to make proactive message calls to users. This appears to be the equivalent code, and should support this feature.

The exact error for this is:

class 'aiohttp.client_exceptions.ClientResponseError'>
Attempt to decode JSON with unexpected mimetype:

We are using the public service url: https://smba.trafficmanager.net/teams/. As suggested in this document.

Steps to Reproduce

Create a message activity with any attachment (Adaptive Card, image, etc.).
Call:

await client.conversations.send_to_conversation(conversation_id, activity)

Service returns 202 with an empty body.
SDK attempts JSON decode and raises an exception.

Impact

This prevents sending any activities with attachments (we are using Adaptive Cards).

Suggested Fixes

Return None if no json response (make the return type union type ResourceResponse | None), as errors are raised if an error status is returned.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions