hermes - 💡(How to fix) Fix test: DingTalk TestIncomingHandlerProcess tests fail when dingtalk-stream SDK is not installed

Official PRs (…)
ON THIS PAGE

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

3 tests in tests/gateway/test_dingtalk.py::TestIncomingHandlerProcess fail with AttributeError: 'NoneType' object has no attribute 'from_dict' because ChatbotMessage is None when dingtalk-stream SDK is not installed.

Error Message

gateway/platforms/dingtalk.py

try: from dingtalk_stream import ChatbotMessage except ImportError: ChatbotMessage = None # <-- this happens when SDK is absent

Root Cause

# gateway/platforms/dingtalk.py
try:
    from dingtalk_stream import ChatbotMessage
except ImportError:
    ChatbotMessage = None  # <-- this happens when SDK is absent

_IncomingHandler.process() calls ChatbotMessage.from_dict(data) at line 1309 without guarding against None, raising AttributeError.

Fix Action

Fix

Tests should mock ChatbotMessage or use pytest.importorskip("dingtalk_stream").

Code Example

# gateway/platforms/dingtalk.py
try:
    from dingtalk_stream import ChatbotMessage
except ImportError:
    ChatbotMessage = None  # <-- this happens when SDK is absent

---

.venv/bin/python -m pytest tests/gateway/test_dingtalk.py::TestIncomingHandlerProcess -v
RAW_BUFFERClick to expand / collapse

Summary

3 tests in tests/gateway/test_dingtalk.py::TestIncomingHandlerProcess fail with AttributeError: 'NoneType' object has no attribute 'from_dict' because ChatbotMessage is None when dingtalk-stream SDK is not installed.

Affected Tests

  • test_process_extracts_session_webhook
  • test_process_returns_ack_immediately
  • test_process_fallback_session_webhook_when_from_dict_misses_it

Root Cause

# gateway/platforms/dingtalk.py
try:
    from dingtalk_stream import ChatbotMessage
except ImportError:
    ChatbotMessage = None  # <-- this happens when SDK is absent

_IncomingHandler.process() calls ChatbotMessage.from_dict(data) at line 1309 without guarding against None, raising AttributeError.

Fix

Tests should mock ChatbotMessage or use pytest.importorskip("dingtalk_stream").

Reproduction

.venv/bin/python -m pytest tests/gateway/test_dingtalk.py::TestIncomingHandlerProcess -v

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING