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

send(suppress=True) causes TypeError: Type is not JSON serializable: flag_value #1674

Closed
3 tasks done
honzajavorek opened this issue Oct 6, 2022 · 0 comments · Fixed by #1719
Closed
3 tasks done
Labels
unconfirmed bug A bug report that needs triaging

Comments

@honzajavorek
Copy link
Contributor

Summary

I upgraded to v2.2.1 and edited my code to use .send(suppress=True) instead of a combo of send & edit(suppress=True). Such change prompted the exception described in the title. I think addition of suppress to sending isn't working correctly.

Reproduction Steps

  1. Get a channel (in my case it's a thread, but I doubt that would be much different?)
  2. Have a working code as follows:
    message = await channel.send(content='blah blah https://junior.guru/handbook/cv/')
    await message.edit(suppress=True)
  3. Upgrade to v2.2.1 or v2.2.2 (doesn't matter) and rewrite code to following:
    await channel.send(content='blah blah https://junior.guru/handbook/cv/', suppress=True)
  4. Get this exception:
    ...
        await thread.send(content=content, suppress=True)
    File "/Users/honza/Library/Caches/pypoetry/virtualenvs/juniorguru-Lgaxwd2n-py3.10/lib/python3.10/site-packages/discord/abc.py", line 1580, in send
        data = await state.http.send_message(
    File "/Users/honza/Library/Caches/pypoetry/virtualenvs/juniorguru-Lgaxwd2n-py3.10/lib/python3.10/site-packages/discord/http.py", line 240, in request
        kwargs["data"] = utils._to_json(kwargs.pop("json"))
    File "/Users/honza/Library/Caches/pypoetry/virtualenvs/juniorguru-Lgaxwd2n-py3.10/lib/python3.10/site-packages/discord/utils.py", line 599, in _to_json
        return orjson.dumps(obj).decode("utf-8")
    TypeError: Type is not JSON serializable: flag_value
    

Minimal Reproducible Code

See reproduction steps.

Expected Results

The code works in the same way as the combo of sending & editing with the suppress keyword argument, saving one API call on its way.

Actual Results

Code crashes.

Intents

guilds, members, message_content

System Information

  • Python v3.10.6-final
  • py-cord v2.2.2-final
  • aiohttp v3.8.3
  • system info: Darwin 21.6.0 Darwin Kernel Version 21.6.0: Mon Aug 22 20:20:05 PDT 2022; root:xnu-8020.140.49~2/RELEASE_ARM64_T8101

(but getting the same error on CI with Linux)

Checklist

  • I have searched the open issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have removed my token from display, if visible.

Additional Context

No response

@honzajavorek honzajavorek added the unconfirmed bug A bug report that needs triaging label Oct 6, 2022
honzajavorek added a commit to juniorguru/junior.guru that referenced this issue Oct 6, 2022
plun1331 added a commit that referenced this issue Oct 22, 2022
@plun1331 plun1331 mentioned this issue Oct 22, 2022
8 tasks
Lulalaby pushed a commit that referenced this issue Oct 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
unconfirmed bug A bug report that needs triaging
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant