fix(gateway): DingTalk adapter compat with dingtalk-stream >= 0.20#9764
Closed
konsisumer wants to merge 1 commit into
Closed
fix(gateway): DingTalk adapter compat with dingtalk-stream >= 0.20#9764konsisumer wants to merge 1 commit into
konsisumer wants to merge 1 commit into
Conversation
dingtalk-stream 0.20+ changed three things that broke the DingTalk adapter: 1. ChatbotHandler.process() is now async — the SDK awaits its return value, causing "object tuple can't be used in 'await' expression" 2. DingTalkStreamClient.start() is now async — asyncio.to_thread() on a coroutine doesn't work, causing "coroutine was never awaited" 3. Messages arrive as CallbackMessage with data in a JSON dict, not as ChatbotMessage with direct attributes — _extract_text() got nothing Fix: make process() async, detect async start() and run it in a fresh event loop on a worker thread, and normalize both message formats through _normalize_message() before processing. Closes NousResearch#9752
Contributor
|
Closing as superseded by #11471 (#11471) which salvaged @kevinskysunny's minimal fix (#11257) and added a follow-up for the broken Thanks for the fix — a lot of contributors hit this SDK break at the same time. Your investigation helped confirm the root cause. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the DingTalk adapter which broke with dingtalk-stream >= 0.20 due to three API changes:
process()is now async — SDK awaits the return value, causing"object tuple can't be used in 'await' expression". Fixed by making_IncomingHandler.process()async.start()is now async —asyncio.to_thread()on a coroutine doesn't work. Fixed by detecting asyncstart()viainspect.iscoroutinefunctionand running it in a fresh event loop on a worker thread.CallbackMessagewith data in a JSON dict, notChatbotMessagewith direct attributes. Fixed by adding_normalize_message()that handles both formats.Backward compatible with dingtalk-stream < 0.20.
Closes #9752
Test plan
_normalize_messagecovering both CallbackMessage (dict data, JSON string data) and legacy ChatbotMessage_run_stream_synchelper