Skip to content

fix(dingtalk): get_connected_platforms + fire-and-forget processing + null-toolsets guard#11605

Merged
teknium1 merged 3 commits into
mainfrom
hermes/hermes-e52e6172
Apr 17, 2026
Merged

fix(dingtalk): get_connected_platforms + fire-and-forget processing + null-toolsets guard#11605
teknium1 merged 3 commits into
mainfrom
hermes/hermes-e52e6172

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Summary

Three DingTalk follow-up fixes in one PR — all from external contributors, all cherry-picked with authorship preserved:

  1. gateway cant add DingTalk platform #11500 @youngDooGatewayConfig.get_connected_platforms() was missing a DingTalk branch entirely. A DingTalk-configured gateway (via YAML extra: or env vars) never appeared in the connected-platforms list, so status displays and iteration callers silently omitted it.

  2. fix(dingtalk): fire-and-forget message processing & session_webhook fallback #11518 @kagura-agent_IncomingHandler.process() currently awaits _on_message directly, which blocks the SDK's recv loop for the full duration of agent processing. For a chat agent responding in 10-30s, this breaks the SDK's heartbeat deadline and causes WebSocket disconnects. Fix: dispatch via asyncio.create_task() so ACK returns immediately. Also adds a defensive session_webhook fallback (raw dict lookup for both sessionWebhook and session_webhook keys) in case a future SDK revision changes the field name. Resolves issue [Bug]: dingtalk channle callback error #11463 (@sgjeff's "No session_webhook available" report).

  3. fix(dingtalk): fix multiple bugs in DingTalk platform adapter #9003 @yyq4193 (one-liner cherry-picked with Co-authored-by trailer) — hermes_cli/tools_config.py was calling config.get("platform_toolsets", {}), which returns None when the YAML key is explicitly null (common with platform_toolsets: and no value below). The next line's .get(platform) then crashed with AttributeError. Changed to config.get(...) or {}.

The rest of #9003 is redundant with #11471 that landed earlier today (webhook regex, async start(), async process(), CallbackMessage → ChatbotMessage) and includes one security regression (https?:// allowing plain HTTP on the webhook allowlist) that I deliberately did not carry over. The tools_config.py one-liner is the only net-new legitimate change from #9003 and I'm landing it here with credit.

Commits (all authorship preserved)

726bea34  Teknium (Co-authored-by: yyq4193)
          test(dingtalk): cover get_connected_platforms + null platform_toolsets
973e0128  kagura-agent
          fix(dingtalk): fire-and-forget message processing & session_webhook fallback
0d2a845f  youngDoo
          gateway cant add DingTalk platform

Merge with --rebase to preserve per-commit authorship.

What I cleaned up

What I deliberately dropped from #9003

  • r'^https?://(api|oapi)\.dingtalk\.com/' — this would re-allow plain HTTP on the webhook URL allowlist. Current main enforces ^https:// only and this is the right security posture. Rejected as a regression.
  • Pre-fix(dingtalk): support dingtalk-stream 0.24+ SDK (async process, CallbackMessage, oapi webhooks, TextContent) #11471 SDK compat changes (async start(), async process(), CallbackMessage → ChatbotMessage, webhook regex oapi accept) — already on main.
  • logger.debug → logger.info for inbound messages — debatable noise; every received message would land in agent.log at INFO. Not carrying over.

Tests

  • tests/gateway/test_dingtalk.py — 50 passed (includes kagura-agent's 3 new TestIncomingHandlerProcess tests + our earlier regression tests)
  • tests/gateway/test_config.py — 28 passed (includes 4 new TestGetConnectedPlatforms::test_dingtalk_* tests I added)
  • tests/hermes_cli/test_tools_config.py — 31 passed (includes test_get_platform_tools_handles_null_platform_toolsets regression test)
  • Combined: 109 passed

Closes

Closes #11500, #11518, #9003 on merge. Should also resolve #11463 (pending @sgjeff pulling latest main).

youngDoo and others added 3 commits April 17, 2026 05:38
gateway cant add DingTalk platform without key and secret
…allback

Fixes #11463: DingTalk channel receives messages but fails to reply
with 'No session_webhook available'.

Two changes:

1. **Fire-and-forget message processing**: process() now dispatches
   _on_message as a background task via asyncio.create_task instead of
   awaiting it. This ensures the SDK ACK is returned immediately,
   preventing heartbeat timeouts and disconnections when message
   processing takes longer than the SDK's ACK deadline.

2. **session_webhook extraction fallback**: If ChatbotMessage.from_dict()
   fails to map the sessionWebhook field (possible across SDK versions),
   the handler now falls back to extracting it directly from the raw
   callback data dict using both 'sessionWebhook' and 'session_webhook'
   key variants.

Added 3 tests covering webhook extraction, fallback behavior, and
fire-and-forget ACK timing.
Follow-ups to the salvaged commits in this PR:

* gateway/config.py — strip trailing whitespace from youngDoo's diff
  (line 315 had ~140 trailing spaces).

* hermes_cli/tools_config.py — replace `config.get("platform_toolsets", {})`
  with `config.get("platform_toolsets") or {}`. Handles the case where the
  YAML key is present but explicitly null (parses as None, previously
  crashed with AttributeError on the next line's .get(platform)).
  Cherry-picked from yyq4193's #9003 with attribution.

* tests/gateway/test_config.py — 4 new tests for TestGetConnectedPlatforms
  covering DingTalk via extras, via env vars, disabled, and missing creds.

* tests/hermes_cli/test_tools_config.py — regression test for the null
  platform_toolsets edge case.

* scripts/release.py — add kagura-agent, youngDoo, yyq4193 to AUTHOR_MAP.

Co-authored-by: yyq4193 <39405770+yyq4193@users.noreply.github.com>
@teknium1 teknium1 merged commit c60b6dc into main Apr 17, 2026
7 checks passed
@teknium1 teknium1 deleted the hermes/hermes-e52e6172 branch April 17, 2026 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: dingtalk channle callback error

3 participants