Skip to content

TeamsFxBotCommandHandler excludes uploaded files from context.activity.attachments when the filename contains "+" and upload from device option is selected #9366

Open
@BeigeBadger

Description

@BeigeBadger

Describe the bug
If a file contains the "+" character in its name it will not have an entry in context.activity.attachments.

I have validated this behaviour with the following file types:

  • .txt
  • .pdf
  • .js

I have also confirmed that:

  • A single "+" with or without surrounding spaces will cause the bug.
  • The onMessage handler of TeamsActivityHandler is also affected by the same bug.
  • Submitting the same file through the "Attach Cloud Files" option works - using OneDrive.
    • The "+" looks to be encoded as "%2B" in the contentUrl.

To Reproduce
Steps to reproduce the behavior:

  1. Use the Command and Response sample.
  2. Inside manifest.json, set bots.supportsFiles to true.
  3. Inside HelloWorldCommandHandler > handleCommandReceived, add the following line:
    • console.log(context.activity.attachments)
    • It may also help to place a breakpoint on this line.
  4. Create a text file called "test1.txt", add some contents (they are irrelevant).
  5. Copy the previous text file and put a "+" somewhere in the name e.g. "test+1.txt" or "test + 1.txt".
  6. Run the sample.
  7. Upload the first text file (without the "+" in the name). select the from this device option, and enter a test message in the chat window (the message is irrelevant), send the message.
  8. Note that attachments contains two elements (the message and the attached file).
  9. Upload the second text file (with the "+" in the name), select the from this device option, and enter a test message in the chat window (the message is irrelevant), send the message.
  10. Note that the attachments array only contains a single element (the message).

Expected behavior
The uploaded file to be present in turn.activity.attachments regardless of which option is used to attach it to the message.

Screenshots
Upload from device options (default):
image

Upload from device behaviour:
image

Attach cloud file options (default):
image

Attach Cloud files behaviour:
image

VS Code Extension Information (please complete the following information):

  • OS: Windows 11 Enterprise
  • Version VS Code: v1.80, Teams Toolkit v5.0.1, Node: v18.17.0,

CLI Information (please complete the following information):

  • OS: Windows 11 Enterprise
  • Version @microsoft/teamsfx v2.2.0

Additional context
package.json

{
    "name": "TeamsToolkitTutorialCommandBot",
    "version": "1.0.0",
    "description": "Microsoft Teams Toolkit Command and Response Bot Sample",
    "engines": {
        "node": "16 || 18"
    },
    "author": "Microsoft",
    "license": "MIT",
    "main": "./lib/index.js",
    "scripts": {
        "dev:teamsfx": "env-cmd --silent -f .localConfigs npm run dev",
        "dev": "nodemon --watch ./src --exec node --inspect=9239 --signal SIGINT -r ts-node/register ./src/index.ts",
        "build": "tsc --build && shx cp -r ./src/adaptiveCards ./lib/src",
        "start": "node ./lib/src/index.js",
        "watch": "nodemon --watch ./src --exec \"npm run start\"",
        "test": "echo \"Error: no test specified\" && exit 1"
    },
    "repository": {
        "type": "git",
        "url": "https://github.com"
    },
    "dependencies": {
        "@azure/identity": "^3.2.3",
        "@microsoft/teamsfx": "^2.2.0",
        "@types/axios": "^0.14.0",
        "axios": "^1.4.0",
        "botbuilder": "^4.18.0",
        "openai": "^3.3.0",
        "pdfjs-dist": "^3.8.162",
        "restify": "^10.0.0"
    },
    "devDependencies": {
        "@types/node": "^14.18.54",
        "@types/restify": "^8.5.5",
        "env-cmd": "^10.1.0",
        "nodemon": "^2.0.7",
        "shx": "^0.3.4",
        "ts-node": "^10.4.0",
        "typescript": "^4.9.5"
    }
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions