diff --git a/nanobot/channels/feishu.py b/nanobot/channels/feishu.py index 3e9db3f4e..7c14651f3 100644 --- a/nanobot/channels/feishu.py +++ b/nanobot/channels/feishu.py @@ -973,11 +973,14 @@ class FeishuChannel(BaseChannel): return None card_id = getattr(response.data, "card_id", None) if card_id: - self._send_message_sync( + message_id = self._send_message_sync( receive_id_type, chat_id, "interactive", json.dumps({"type": "card", "data": {"card_id": card_id}}), ) - return card_id + if message_id: + return card_id + logger.warning("Created streaming card {} but failed to send it to {}", card_id, chat_id) + return None except Exception as e: logger.warning("Error creating streaming card: {}", e) return None diff --git a/tests/channels/test_feishu_streaming.py b/tests/channels/test_feishu_streaming.py index 5532f0635..22ad8cbc6 100644 --- a/tests/channels/test_feishu_streaming.py +++ b/tests/channels/test_feishu_streaming.py @@ -82,6 +82,17 @@ class TestCreateStreamingCard: ch._client.cardkit.v1.card.create.side_effect = RuntimeError("network") assert ch._create_streaming_card_sync("chat_id", "oc_chat1") is None + def test_returns_none_when_card_send_fails(self): + ch = _make_channel() + ch._client.cardkit.v1.card.create.return_value = _mock_create_card_response("card_123") + resp = MagicMock() + resp.success.return_value = False + resp.code = 99999 + resp.msg = "error" + resp.get_log_id.return_value = "log1" + ch._client.im.v1.message.create.return_value = resp + assert ch._create_streaming_card_sync("chat_id", "oc_chat1") is None + class TestCloseStreamingMode: def test_returns_true_on_success(self):