file info in attachments field in the request body is missing! when receiving files using bots.
Background
We are using bot service. The Config in Azure Portal is like the picture below.
When user send some thing to the bot via teams, the bot service will redirect the request to the endpoint which is directed to our server.
User can send normal text and attachment file to the bot.
When user send text and attachments file to the bot
Our message endpoint will get the request from bot service and the body is like this
2022/09/02 06:29:08.034127 DEBUG RESTY
==============================================================================
~~~ REQUEST ~~~
POST out message endpoint HTTP/1.1
HOST : host.docker.internal
HEADERS:
Accept: application/json;charset=utf-8
Content-Type: application/json;charset=utf-8
User-Agent: go-resty/2.3.0 (https://github.com/go-resty/resty)
BODY :
{
"type": "text",
"session_id": "teams::conversationID",
"text": "text with attachment",
"data_config_index": "8",
"location": "location url",
"original_request": {
"from": "teams",
"body": {
"text": "text with attachment",
"type": "message",
"timestamp": "2055-10-02T06:29:02.4103628Z",
"id": "id",
"channelId": "msteams",
"serviceUrl": "https://smba.trafficmanager.net/jp/",
"from": {
"id": "id",
"name": "name",
"aadObjectId": "id"
},
"conversation": {
"conversationType": "personal",
"tenantId": "tenantId",
"id": "id"
},
"recipient": {
"id": "id",
"name": "name"
},
"channelData": {
"tenant": {
"id": "id"
}
},
"attachments": [
{
"content": {
"downloadUrl": "downloadUrl?Version=2.0",
"fileType": "png",
"uniqueId": "uniqueId"
},
"contentType": "application/vnd.microsoft.teams.file.download.info",
"contentUrl": "https://xxxxxxx-my.sharepoint.com/personal/xxxxxxxxx/Documents/Microsoft Teams Chat Files/attachments.png",
"name": "attachments.png"
},
{
"content": "\u003cp\u003etext with attachment\u003c/p\u003e",
"contentType": "text/html"
}
],
"entities": [
{
"country": "country",
"locale": "local",
"platform": "Web",
"timezone": "somewhere in earth/somewhere in earth",
"type": "clientInfo"
}
],
"locale": "somecode-somecountryCode"
}
}
}
Issue Case
Describe
But some time when user send a attachment file to the bot, file info in attachments field in the request body is missing! 。
This is seldom occurred but it does occurred. We checked the error log on our server but no thing happed when the strange case happened.
And from our request log, we can see that the body in the request is unusual.
So we are doubting that is it caused by the reason that the rate limit for file attachment is reached and bot service stopped to deal with the attachment file?
~~~ REQUEST ~~~
POST out message endpoint HTTP/1.1
HOST : host.docker.internal
HEADERS:
Accept: application/json;charset=utf-8
Content-Type: application/json;charset=utf-8
User-Agent: go-resty/2.3.0 (https://github.com/go-resty/resty)
BODY :
{
"type": "text",
"session_id": "teams::conversationID",
"text": "text with attachment",
"data_config_index": "8",
"location": "location url",
"original_request": {
"from": "teams",
"body": {
"text": "text with attachment",
"type": "message",
"timestamp": "2055-10-02T06:29:02.4103628Z",
"id": "id",
"channelId": "msteams",
"serviceUrl": "https://smba.trafficmanager.net/jp/",
"from": {
"id": "id",
"name": "name",
"aadObjectId": "id"
},
"conversation": {
"conversationType": "personal",
"tenantId": "tenantId",
"id": "id"
},
"recipient": {
"id": "id",
"name": "name"
},
"channelData": {
"tenant": {
"id": "id"
}
},
"attachments": [
// Where is our attachemt file info?
{
"content": "\u003cp\u003etext with attachment\u003c/p\u003e",
"contentType": "text/html"
}
],
"entities": [
{
"country": "country",
"locale": "local",
"platform": "Web",
"timezone": "somewhere in earth/somewhere in earth",
"type": "clientInfo"
}
],
"locale": "somecode-somecountryCode"
}
}
}
We should get item with the contentType of "application/vnd.microsoft.teams.file.download.info" but we didn't.
The following attachment info is missing
{
"content": {
"downloadUrl": "downloadUrl?Version=2.0",
"fileType": "png",
"uniqueId": "uniqueId"
},
"contentType": "application/vnd.microsoft.teams.file.download.info",
"contentUrl": "https://xxxxxxx-my.sharepoint.com/personal/xxxxxxxxx/Documents/Microsoft Teams Chat Files/attachments.png",
"name": "attachments.png"
},
This is unexpected case as the formal document described that "Your bot will then receive a message activity notifying you of the user upload. The activity will contain file metadata, such as its name and the content URL. You can directly read from this URL to fetch its binary content."
Does anyone occurred into this case? Or does anyone knows about the reason why this case could happen?