microsoft / teams-ai

SDK focused on building AI based applications and extensions for Microsoft Teams and other Bot Framework channels
MIT License
349 stars 142 forks source link

[Bug]: If you send a message without any text and only an image, there is an exception #1777

Open heyitsaamir opened 4 days ago

heyitsaamir commented 4 days ago

Language

Python

Version

latest

Description

The bug is here - https://github.com/microsoft/teams-ai/blob/2b787dbd5d923df0a6b0ea23b236686afdd83220/python/packages/ai/teams/app.py#L253

If you paste an image and send it, you get an exception that looks like this:

 [on_turn_error] unhandled error: 'NoneType' object has no attribute 'find'
Traceback (most recent call last):
  File "workspace/.venv/lib/python3.11/site-packages/botbuilder/core/bot_adapter.py", line 174, in run_pipeline
    return await self._middleware.receive_activity_with_status(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "workspace/.venv/lib/python3.11/site-packages/botbuilder/core/middleware_set.py", line 69, in receive_activity_with_status
    return await self.receive_activity_internal(context, callback)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "workspace/.venv/lib/python3.11/site-packages/botbuilder/core/middleware_set.py", line 79, in receive_activity_internal
    return await callback(context)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "workspace/.venv/lib/python3.11/site-packages/teams/app.py", line 663, in on_turn
    await self._start_long_running_call(context, self._on_turn)
  File "workspace/.venv/lib/python3.11/site-packages/teams/app.py", line 813, in _start_long_running_call
    return await func(context)
           ^^^^^^^^^^^^^^^^^^^
  File "workspace/.venv/lib/python3.11/site-packages/teams/app.py", line 742, in _on_turn
    is_ok, matches = await self._on_activity(context, state)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "workspace/.venv/lib/python3.11/site-packages/teams/app.py", line 790, in _on_activity
    for route in routes:
  File "workspace/.venv/lib/python3.11/site-packages/teams/app.py", line 780, in <lambda>
    routes = filter(lambda r: not r.is_invoke and r.selector(context), self._routes)
                                                  ^^^^^^^^^^^^^^^^^^^
  File "workspace/.venv/lib/python3.11/site-packages/teams/app.py", line 253, in __selector__
    i = context.activity.text.find(select)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'find'

Reproduction Steps

1. Have your python handler be running
2. Send an image from Teams that only contains an image
BMS-geodev commented 2 days ago

test comment