Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

During the response to InlineQuery an error occurs if I do not specify parse_mode in InputTextMessageContent #660

Closed
t3m8ch opened this issue Aug 7, 2021 · 1 comment
Labels
3.x Issue or PR for stable 3.x version bug Something is wrong with the framework

Comments

@t3m8ch
Copy link

t3m8ch commented Aug 7, 2021

Context

  • Operating System: Fedora Linux 34 Workstation
  • Python Version: Python 3.9.6
  • aiogram version: 3.0.0a12
  • aiohttp version: 3.7.4.post0
  • uvloop version (if installed): not installed
  • Dependencies management: Poetry 1.1.6

Expected Behavior

The bot will successfully respond to InlineQuery

Current Behavior

A TypeError exception is thrown with the message: Object of type _SentinelObject is not JSON serializable

Failure Information (for bugs)

If you explicitly specify the parse_mode parameter when creating an object of type InputTextMessageContent (even if it is an empty string), an exception is not thrown and the bot successfully responds to the user

Steps to Reproduce

https://gist.github.com/t3m8ch/3e6d484c04c2e9e487acb948f093c617

Failure Logs

https://gist.github.com/t3m8ch/3e6d484c04c2e9e487acb948f093c617#file-logs-txt

@evgfilim1 evgfilim1 added 3.x Issue or PR for stable 3.x version bug Something is wrong with the framework labels Aug 8, 2021
@darksidecat
Copy link
Contributor

darksidecat commented Aug 8, 2021

Problem here:

prepare_parse_mode(bot, data["results"])

Must be something like:

input_message_contents = []
for result in data["results"]:
    if result.get("input_message_content", None) is not None:
        input_message_contents.append(result.get("input_message_content"))

prepare_parse_mode(
    bot,
    data["results"]+input_message_contents
)

darksidecat added a commit to darksidecat/aiogram that referenced this issue Aug 8, 2021
JrooTJunior pushed a commit that referenced this issue Aug 16, 2021
* fix #660 prepare parse mode for input_message_content of InlineQueryResult

* remove redundant get

* black lint

* add towncrier patch note
@gabbhack gabbhack closed this as completed Oct 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.x Issue or PR for stable 3.x version bug Something is wrong with the framework
Projects
None yet
Development

No branches or pull requests

4 participants