Skip to content

fix(gateway/dingtalk): allow oapi.dingtalk.com webhook + correctness fixes#8957

Closed
sputnicyoji wants to merge 1 commit into
NousResearch:mainfrom
sputnicyoji:fix/dingtalk-oapi-webhook
Closed

fix(gateway/dingtalk): allow oapi.dingtalk.com webhook + correctness fixes#8957
sputnicyoji wants to merge 1 commit into
NousResearch:mainfrom
sputnicyoji:fix/dingtalk-oapi-webhook

Conversation

@sputnicyoji

Copy link
Copy Markdown

Summary

A blocking SSRF-regex bug plus a handful of small correctness issues in the DingTalk adapter:

  • oapi.dingtalk.com allowed in webhook origin check. The current regex accepts only api.dingtalk.com, but DingTalk's group-chat session webhooks come from oapi.dingtalk.com. In any real group/org deployment every reply fails with "No session_webhook available. Reply must follow an incoming message.". Broaden the regex to https://(?:o?api)\.dingtalk\.com/.
  • FIFO eviction no longer drops a still-valid entry. _session_webhooks popped the head even when the incoming chat_id was already in the dict — silently evicting a valid entry on rewrite. Skip eviction when the key is a rewrite.
  • get_chat_info uses an authoritative chat-type map. Previous heuristic ("group" in chat_id.lower()) never matches real cidXXXX== DingTalk conversation ids. Track _chat_types populated from conversation_type during inbound.
  • send() logs a warning when truncating at MAX_MESSAGE_LENGTH instead of silently clipping.
  • Name the stream task (<platform>-stream) so it shows up usefully in asyncio.all_tasks() dumps.

Test plan

  • Existing tests pass (21).
  • Verified locally: group-chat @bot with a real oapi.dingtalk.com session webhook now replies successfully.

Builds cleanly on top of #8954 (SDK 0.24 compat) or on its own against main.

…fixes

A blocking SSRF-regex bug plus a handful of small correctness issues
found in the DingTalk adapter:

- The SSRF origin check accepts only `api.dingtalk.com`, but DingTalk's
  group-chat session webhooks come from `oapi.dingtalk.com`. In any
  real group/org deployment every reply fails with
  "No session_webhook available." Broaden the regex to
  `https://(?:o?api)\.dingtalk\.com/`.

- FIFO eviction of `_session_webhooks` pops the head even when the
  incoming `chat_id` is already in the dict — silently evicting a
  still-valid entry. Skip eviction when the key is a rewrite.

- `get_chat_info` inferred `"group"` from the string
  `"group" in chat_id.lower()`, which is wrong for every real
  `cidXXXX==` DingTalk conversation id. Track an explicit
  `_chat_types` map populated from `conversation_type` during inbound.

- `send()` silently truncated long replies at `MAX_MESSAGE_LENGTH`;
  log a `warning` so the truncation is visible in operator logs.

- Name the stream task (`<platform>-stream`) so it shows up usefully in
  `asyncio.all_tasks()` dumps.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@teknium1

Copy link
Copy Markdown
Contributor

Closing — the oapi.dingtalk.com webhook domain is now accepted on main as of #11471 (#11471). Thanks for catching and reporting this.

@teknium1 teknium1 closed this Apr 17, 2026
@sputnicyoji

Copy link
Copy Markdown
Author

Thanks for the follow-up and for landing the fix via #11471 — glad the issue is now resolved on main. Appreciate the maintenance work.

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.

2 participants